File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
app/code/Magento/Catalog/Model/Product Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,7 @@ public function copy(\Magento\Catalog\Model\Product $product)
60
60
/** @var \Magento\Catalog\Model\Product $duplicate */
61
61
$ duplicate = $ this ->productFactory ->create ();
62
62
$ productData = $ product ->getData ();
63
- if (isset ($ productData [ProductInterface::EXTENSION_ATTRIBUTES_KEY ])) {
64
- $ extensionAttributes = $ productData [ProductInterface::EXTENSION_ATTRIBUTES_KEY ];
65
- if (null !== $ extensionAttributes ->getStockItem ()) {
66
- $ extensionAttributes ->setData ('stock_item ' , null );
67
- }
68
- }
63
+ $ productData = $ this ->removeStockItem ($ productData );
69
64
$ duplicate ->setData ($ productData );
70
65
$ duplicate ->setOptions ([]);
71
66
$ duplicate ->setIsDuplicate (true );
@@ -123,4 +118,21 @@ private function getMetadataPool()
123
118
}
124
119
return $ this ->metadataPool ;
125
120
}
121
+
122
+ /**
123
+ * Remove stock item
124
+ *
125
+ * @param array $productData
126
+ * @return array
127
+ */
128
+ private function removeStockItem (array $ productData )
129
+ {
130
+ if (isset ($ productData [ProductInterface::EXTENSION_ATTRIBUTES_KEY ])) {
131
+ $ extensionAttributes = $ productData [ProductInterface::EXTENSION_ATTRIBUTES_KEY ];
132
+ if (null !== $ extensionAttributes ->getStockItem ()) {
133
+ $ extensionAttributes ->setData ('stock_item ' , null );
134
+ }
135
+ }
136
+ return $ productData ;
137
+ }
126
138
}
You can’t perform that action at this time.
0 commit comments