7
7
namespace Magento \Catalog \Model ;
8
8
9
9
use Magento \Catalog \Api \CategoryLinkManagementInterface ;
10
- use Magento \Catalog \Api \Data \ProductAttributeInterface ;
11
10
use Magento \Catalog \Api \Data \ProductExtension ;
12
11
use Magento \Catalog \Api \Data \ProductInterface ;
13
12
use Magento \Catalog \Controller \Adminhtml \Product \Initialization \Helper \AttributeFilter ;
@@ -188,10 +187,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
188
187
*/
189
188
private $ scopeOverriddenValue ;
190
189
191
- /**
192
- * @var AttributeFilter
193
- */
194
- private $ attributeFilter ;
195
190
196
191
/**
197
192
* ProductRepository constructor.
@@ -214,7 +209,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
214
209
* @param MimeTypeExtensionMap $mimeTypeExtensionMap
215
210
* @param ImageProcessorInterface $imageProcessor
216
211
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
217
- * @param AttributeFilter|null $attributeFilter
218
212
* @param CollectionProcessorInterface $collectionProcessor [optional]
219
213
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
220
214
* @param int $cacheLimit [optional]
@@ -244,7 +238,6 @@ public function __construct(
244
238
MimeTypeExtensionMap $ mimeTypeExtensionMap ,
245
239
ImageProcessorInterface $ imageProcessor ,
246
240
\Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface $ extensionAttributesJoinProcessor ,
247
- AttributeFilter $ attributeFilter = null ,
248
241
CollectionProcessorInterface $ collectionProcessor = null ,
249
242
\Magento \Framework \Serialize \Serializer \Json $ serializer = null ,
250
243
$ cacheLimit = 1000 ,
@@ -599,56 +592,35 @@ public function save(ProductInterface $product, $saveOptions = false)
599
592
$ websites = null ;
600
593
}
601
594
602
- $ useDefault = [];
603
595
if (!empty ($ existingProduct ) && is_array ($ stores ) && is_array ($ websites )) {
604
596
$ hasDataChanged = false ;
605
597
$ productAttributes = $ product ->getAttributes ();
606
598
if ($ productAttributes !== null
607
599
&& $ product ->getStoreId () !== Store::DEFAULT_STORE_ID
608
600
&& (count ($ stores ) > 1 || count ($ websites ) >= 1 )
609
601
) {
610
- $ imageRoles = ['image ' , 'small_image ' , 'thumbnail ' ];
611
- foreach ($ product ->getAttributes () as $ attribute ) {
612
- $ defaultValue = $ attribute ->getDefaultValue ();
602
+ foreach ($ productAttributes as $ attribute ) {
613
603
$ attributeCode = $ attribute ->getAttributeCode ();
614
604
$ value = $ product ->getData ($ attributeCode );
615
- if ($ defaultValue
616
- && $ defaultValue === $ value
617
- && $ value !== null
605
+ if ($ existingProduct ->getData ($ attributeCode ) === $ value
618
606
&& $ attribute ->getScope () !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
607
+ && !is_array ($ value )
608
+ && !$ attribute ->isStatic ()
609
+ && $ value !== null
619
610
&& !$ this ->scopeOverriddenValue ->containsValue (
620
611
ProductInterface::class,
621
612
$ product ,
622
613
$ attributeCode ,
623
614
$ product ->getStoreId ()
624
615
)
625
616
) {
626
- $ useDefault [$ attributeCode ] = '1 ' ;
627
- } elseif (!$ defaultValue && $ value !== null
628
- && !in_array ($ attributeCode , $ imageRoles )
629
- && $ attribute ->getScope () !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
630
- && $ existingProduct ->getData ($ attributeCode ) === $ value
631
- && $ existingProduct ->getOrigData ($ attributeCode ) === $ value
632
- && !$ this ->scopeOverriddenValue ->containsValue (
633
- ProductInterface::class,
634
- $ product ,
617
+ $ product ->setData (
635
618
$ attributeCode ,
636
- $ product ->getStoreId ()
637
- )
638
- ) {
639
- $ useDefault [$ attributeCode ] = '1 ' ;
640
- } else {
641
- $ useDefault [$ attributeCode ] = '0 ' ;
619
+ $ attributeCode === ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY ? false : null
620
+ );
642
621
$ hasDataChanged = true ;
643
622
}
644
623
}
645
- $ productDataArray = $ this ->attributeFilter ->prepareProductAttributes (
646
- $ product ,
647
- $ productDataArray ,
648
- $ useDefault
649
- );
650
- $ product ->setData ($ productDataArray );
651
-
652
624
if ($ hasDataChanged ) {
653
625
$ product ->setData ('_edit_mode ' , true );
654
626
}
0 commit comments