File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed
app/code/Magento/Catalog/Model
dev/tests/integration/testsuite/Magento/Catalog/Model Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -948,12 +948,14 @@ public function beforeSave()
948
948
)
949
949
&& !$ this ->authorization ->isAllowed ('Magento_Catalog::edit_category_design ' )
950
950
) {
951
- $ this ->setData ('custom_design ' , $ this ->getOrigData ('custom_design ' ));
952
- $ this ->setData ('custom_design_from ' , $ this ->getOrigData ('custom_design_from ' ));
953
- $ this ->setData ('custom_design_to ' , $ this ->getOrigData ('custom_design_to ' ));
954
- $ this ->setData ('page_layout ' , $ this ->getOrigData ('page_layout ' ));
955
- $ this ->setData ('custom_layout_update ' , $ this ->getOrigData ('custom_layout_update ' ));
956
- $ this ->setData ('custom_apply_to_products ' , $ this ->getOrigData ('custom_apply_to_products ' ));
951
+ $ this ->getCustomAttributes ();
952
+ foreach ($ this ->_designAttributes as $ attributeCode ) {
953
+ $ this ->setData ($ attributeCode , $ value = $ this ->getOrigData ($ attributeCode ));
954
+ if (array_key_exists ($ attributeCode , $ this ->_data [self ::CUSTOM_ATTRIBUTES ])) {
955
+ //In case custom attribute were used to update the entity.
956
+ $ this ->_data [self ::CUSTOM_ATTRIBUTES ][$ attributeCode ]->setValue ($ value );
957
+ }
958
+ }
957
959
}
958
960
959
961
return parent ::beforeSave ();
Original file line number Diff line number Diff line change @@ -104,9 +104,6 @@ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category)
104
104
}
105
105
}
106
106
} else {
107
- //Clearing all redundant data and using only properly extracted data for the entity.
108
- /** @var Category $category */
109
- $ category = $ this ->categoryFactory ->create ();
110
107
$ parentId = $ category ->getParentId () ?: $ this ->storeManager ->getStore ()->getRootCategoryId ();
111
108
$ parentCategory = $ this ->get ($ parentId , $ storeId );
112
109
$ existingData ['path ' ] = $ parentCategory ->getPath ();
Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ public function testSaveDesign()
85
85
86
86
$ category ->setCustomAttribute ('custom_design ' , 2 );
87
87
$ category = $ this ->repo ->save ($ category );
88
- $ this ->assertEmpty ($ category ->getCustomAttribute ('custom_design ' ));
88
+ $ customDesignAttribute = $ category ->getCustomAttribute ('custom_design ' );
89
+ $ this ->assertTrue (!$ customDesignAttribute || !$ customDesignAttribute ->getValue ());
89
90
90
91
//Admin has access to category' design.
91
92
$ this ->aclBuilder ->getAcl ()
@@ -105,6 +106,7 @@ public function testSaveDesign()
105
106
$ this ->aclBuilder ->getAcl ()->deny (null , 'Magento_Catalog::edit_category_design ' );
106
107
$ newCategory ->setCustomAttribute ('custom_design ' , 2 );
107
108
$ newCategory = $ this ->repo ->save ($ newCategory );
108
- $ this ->assertEmpty ($ newCategory ->getCustomAttribute ('custom_design ' ));
109
+ $ customDesignAttribute = $ newCategory ->getCustomAttribute ('custom_design ' );
110
+ $ this ->assertTrue (!$ customDesignAttribute || !$ customDesignAttribute ->getValue ());
109
111
}
110
112
}
You can’t perform that action at this time.
0 commit comments