Skip to content

Commit 306ba37

Browse files
committed
AC-2904-v1:: Saving product with non-default store scope causes untouched attributes to become store scoped if loaded using ProductRepository
1 parent ecf4680 commit 306ba37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ public function save(ProductInterface $product, $saveOptions = false)
525525
{
526526
$assignToCategories = false;
527527
$tierPrices = $product->getData('tier_price');
528-
$productDataToChange = $product->getData();
529528

530529
try {
531530
$existingProduct = $product->getId() ?
@@ -597,10 +596,12 @@ public function save(ProductInterface $product, $saveOptions = false)
597596
&& $product->getStoreId() !== Store::DEFAULT_STORE_ID
598597
&& (count($stores) > 1 || count($websites) === 1)
599598
) {
599+
$imageRoles = ['image', 'small_image', 'thumbnail'];
600600
foreach ($productAttributes as $attribute) {
601601
$attributeCode = $attribute->getAttributeCode();
602602
$value = $product->getData($attributeCode);
603-
if ($existingProduct->getData($attributeCode) === $value
603+
if (!in_array($attributeCode, $imageRoles)
604+
&& $existingProduct->getData($attributeCode) === $value
604605
&& $existingProduct->getOrigData($attributeCode) === $value
605606
&& $attribute->getScope() !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
606607
&& !is_array($value)
@@ -627,7 +628,6 @@ public function save(ProductInterface $product, $saveOptions = false)
627628
}
628629

629630
$this->saveProduct($product);
630-
631631
if ($assignToCategories === true && $product->getCategoryIds()) {
632632
$this->linkManagement->assignProductToCategories(
633633
$product->getSku(),

0 commit comments

Comments
 (0)