@@ -214,6 +214,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
214
214
* @param MimeTypeExtensionMap $mimeTypeExtensionMap
215
215
* @param ImageProcessorInterface $imageProcessor
216
216
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
217
+ * @param AttributeFilter|null $attributeFilter
217
218
* @param CollectionProcessorInterface $collectionProcessor [optional]
218
219
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
219
220
* @param int $cacheLimit [optional]
@@ -534,7 +535,6 @@ public function save(ProductInterface $product, $saveOptions = false)
534
535
{
535
536
$ assignToCategories = false ;
536
537
$ tierPrices = $ product ->getData ('tier_price ' );
537
- $ productDataToChange = $ product ->getData ();
538
538
539
539
try {
540
540
$ existingProduct = $ product ->getId () ?
@@ -599,15 +599,14 @@ public function save(ProductInterface $product, $saveOptions = false)
599
599
$ websites = null ;
600
600
}
601
601
602
+ $ useDefault = [];
602
603
if (!empty ($ existingProduct ) && is_array ($ stores ) && is_array ($ websites )) {
603
604
$ hasDataChanged = false ;
604
605
$ productAttributes = $ product ->getAttributes ();
605
606
if ($ productAttributes !== null
606
607
&& $ product ->getStoreId () !== Store::DEFAULT_STORE_ID
607
608
&& (count ($ stores ) > 1 || count ($ websites ) === 1 )
608
609
) {
609
-
610
- $ useDefault = [];
611
610
foreach ($ product ->getAttributes () as $ attribute ) {
612
611
$ defaultValue = $ attribute ->getDefaultValue ();
613
612
$ attributeCode = $ attribute ->getAttributeCode ();
@@ -624,7 +623,6 @@ public function save(ProductInterface $product, $saveOptions = false)
624
623
)
625
624
) {
626
625
$ useDefault [$ attributeCode ] = '1 ' ;
627
- $ hasDataChanged = true ;
628
626
} elseif (!$ defaultValue && $ value !== null
629
627
&& $ attribute ->getScope () !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
630
628
&& $ existingProduct ->getData ($ attributeCode ) === $ value
@@ -636,20 +634,16 @@ public function save(ProductInterface $product, $saveOptions = false)
636
634
)
637
635
) {
638
636
$ useDefault [$ attributeCode ] = '1 ' ;
639
- $ hasDataChanged = true ;
640
637
} else {
641
638
$ useDefault [$ attributeCode ] = '0 ' ;
639
+ $ hasDataChanged = true ;
642
640
}
643
-
644
641
}
645
642
if ($ hasDataChanged ) {
646
643
$ product ->setData ('_edit_mode ' , true );
647
644
}
648
645
}
649
646
}
650
- $ productDataArray = $ this ->extensibleDataObjectConverter
651
- ->toNestedArray ($ product , [], ProductInterface::class);
652
- $ productDataArray = array_replace ($ productDataArray , $ product ->getData ());
653
647
654
648
$ productDataArray = $ this ->attributeFilter ->prepareProductAttributes (
655
649
$ product ,
@@ -658,6 +652,7 @@ public function save(ProductInterface $product, $saveOptions = false)
658
652
);
659
653
$ newProduct = $ this ->productFactory ->create ();
660
654
$ newProduct ->setData ($ productDataArray );
655
+
661
656
$ this ->saveProduct ($ newProduct );
662
657
663
658
if ($ assignToCategories === true && $ product ->getCategoryIds ()) {
0 commit comments