@@ -620,6 +620,46 @@ public function save(ProductInterface $product, $saveOptions = false)
620
620
$ hasDataChanged = true ;
621
621
}
622
622
}
623
+ $ storeScopedAttributes = [
624
+ ProductAttributeInterface::CODE_SEO_FIELD_META_TITLE ,
625
+ ProductAttributeInterface::CODE_SEO_FIELD_META_DESCRIPTION ,
626
+ ProductAttributeInterface::CODE_SEO_FIELD_META_KEYWORD ,
627
+ ];
628
+ $ origDataAttributes = [
629
+ ProductAttributeInterface::CODE_NAME ,
630
+ ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY ,
631
+ ];
632
+ foreach ($ product ->getAttributes () as $ attribute ) {
633
+ $ defaultValue = $ attribute ->getDefaultValue ();
634
+ $ attributeCode = $ attribute ->getAttributeCode ();
635
+ $ value = $ product ->getData ($ attributeCode );
636
+ if ($ defaultValue
637
+ && $ defaultValue === $ value
638
+ && $ value !== null
639
+ && $ attribute ->getScope () !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
640
+ && !$ this ->scopeOverriddenValue ->containsValue (
641
+ ProductInterface::class,
642
+ $ product ,
643
+ $ attributeCode ,
644
+ $ product ->getStoreId ()
645
+ )
646
+ ) {
647
+ $ product ->setData ($ attributeCode );
648
+ $ hasDataChanged = true ;
649
+ } elseif (!$ defaultValue && $ value !== null
650
+ && $ attribute ->getScope () === EavAttributeInterface::SCOPE_STORE_TEXT
651
+ && $ existingProduct ->getData ($ attributeCode ) === $ value
652
+ && in_array ($ attributeCode , $ storeScopedAttributes )
653
+ ) {
654
+ $ product ->setData ($ attributeCode );
655
+ $ hasDataChanged = true ;
656
+ } elseif (in_array ($ attributeCode , $ origDataAttributes )
657
+ && $ existingProduct ->getOrigData ($ attributeCode ) === $ value
658
+ ) {
659
+ $ product ->setData ($ attributeCode );
660
+ $ hasDataChanged = true ;
661
+ }
662
+ }
623
663
if ($ hasDataChanged ) {
624
664
$ product ->setData ('_edit_mode ' , true );
625
665
}
0 commit comments