@@ -77,14 +77,7 @@ public function __construct(
77
77
public function save (\Magento \Catalog \Api \Data \CategoryInterface $ category )
78
78
{
79
79
$ storeId = (int )$ this ->storeManager ->getStore ()->getId ();
80
- $ existingData = $ this ->getExtensibleDataObjectConverter ()
81
- ->toNestedArray ($ category , [], \Magento \Catalog \Api \Data \CategoryInterface::class);
82
- $ existingData = array_diff_key ($ existingData , array_flip (['path ' , 'level ' , 'parent_id ' ]));
83
- $ existingData ['store_id ' ] = $ storeId ;
84
-
85
- if (is_array ($ category ->getData ())) {
86
- $ existingData = array_replace ($ existingData , $ category ->getData ());
87
- }
80
+ $ existingData = $ this ->getExistingData ($ category , $ storeId );
88
81
89
82
if ($ category ->getId ()) {
90
83
$ metadata = $ this ->getMetadataPool ()->getMetadata (
@@ -243,4 +236,25 @@ private function getMetadataPool()
243
236
}
244
237
return $ this ->metadataPool ;
245
238
}
239
+
240
+ /**
241
+ * Get existing data category
242
+ *
243
+ * @param CategoryInterface $category
244
+ * @param int $storeId
245
+ * @return array
246
+ */
247
+ private function getExistingData (CategoryInterface $ category , int $ storeId )
248
+ {
249
+ $ existingData = $ this ->getExtensibleDataObjectConverter ()
250
+ ->toNestedArray ($ category , [], \Magento \Catalog \Api \Data \CategoryInterface::class);
251
+ $ existingData = array_diff_key ($ existingData , array_flip (['path ' , 'level ' , 'parent_id ' ]));
252
+ $ existingData ['store_id ' ] = $ storeId ;
253
+
254
+ if (is_array ($ category ->getData ())) {
255
+ $ existingData = array_replace ($ existingData , $ category ->getData ());
256
+ }
257
+
258
+ return $ existingData ;
259
+ }
246
260
}
0 commit comments