12
12
use Magento \Store \Model \StoreManagerInterface ;
13
13
14
14
/**
15
- * Class Save
15
+ * Category save controller
16
16
*
17
17
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18
18
*/
@@ -144,10 +144,10 @@ public function execute()
144
144
$ categoryPostData = $ this ->stringToBoolConverting ($ categoryPostData );
145
145
$ categoryPostData = $ this ->imagePreprocessing ($ categoryPostData );
146
146
$ categoryPostData = $ this ->dateTimePreprocessing ($ category , $ categoryPostData );
147
- $ storeId = isset ( $ categoryPostData ['store_id ' ]) ? $ categoryPostData [ ' store_id ' ] : null ;
147
+ $ storeId = $ categoryPostData ['store_id ' ] ?? null ;
148
148
$ store = $ this ->storeManager ->getStore ($ storeId );
149
149
$ this ->storeManager ->setCurrentStore ($ store ->getCode ());
150
- $ parentId = isset ( $ categoryPostData ['parent ' ]) ? $ categoryPostData [ ' parent ' ] : null ;
150
+ $ parentId = $ categoryPostData ['parent ' ] ?? null ;
151
151
if ($ categoryPostData ) {
152
152
$ category ->addData ($ categoryPostData );
153
153
if ($ parentId ) {
@@ -168,7 +168,7 @@ public function execute()
168
168
if (isset ($ categoryPostData ['use_config ' ]) && !empty ($ categoryPostData ['use_config ' ])) {
169
169
foreach ($ categoryPostData ['use_config ' ] as $ attributeCode => $ attributeValue ) {
170
170
if ($ attributeValue ) {
171
- $ useConfig [] = $ attributeCode ;
171
+ $ useConfig [] = $ attributeValue ;
172
172
$ category ->setData ($ attributeCode , null );
173
173
}
174
174
}
@@ -220,7 +220,11 @@ public function execute()
220
220
__ ('The "%1" attribute is required. Enter and try again. ' , $ attribute )
221
221
);
222
222
} else {
223
- $ this ->messageManager ->addErrorMessage (__ ('Something went wrong while saving the category. ' ));
223
+ $ this ->messageManager ->addErrorMessage (
224
+ __ (
225
+ 'Something went wrong while saving the category. '
226
+ )
227
+ );
224
228
$ this ->logger ->critical ('Something went wrong while saving the category. ' );
225
229
$ this ->_getSession ()->setCategoryData ($ categoryPostData );
226
230
}
0 commit comments