Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving via ProductRepository changes untouched attributes #7879

Closed
ochnygosch opened this issue Dec 19, 2016 · 6 comments
Closed

Saving via ProductRepository changes untouched attributes #7879

ochnygosch opened this issue Dec 19, 2016 · 6 comments
Labels
bug report Component: Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@ochnygosch
Copy link
Contributor

Saving a loaded product via the ProductRepository updates attribute values of unchanged attributes. Even loading a product and saving it without making changes can lead to a product no longer using default values for a store.

Preconditions

  1. Magento 2.1.3
  2. Single store mode is disabled

Steps to reproduce

  1. Create a simple product
  2. Make sure this product uses default value for product name (or other attributes) for default store
  3. Load product in a backend controller via getById($productId) method of ProductRepositoryInterface
  4. Save the loaded product via save($product) method of ProductRepositoryInterface

Expected result

  1. No attribute value of the product should have changed. Especially the product name in store 1 should still use the default value

Actual result

  1. The name of the save product is copied from store 0 to store 1 and store 1 no longer uses the default value for the product name

Attached is a sample module that provides a backend controller that loads product with id 1 and saves it without changing an attribute.
ProductSave.zip

@ochnygosch
Copy link
Contributor Author

I think something in the eav system is seriously broken.

I've tried adding another website with a store and store view (say having the id 2).

Having a product (with id 1) and the following values:

Store 0 Name: "Testproduct"
Store 1 Name: Use default value
Store 2 Name: Use default value

Store 0 Description: "Test description"
Store 1 Description: Use default value
Store 2 Description: "Test description in store 2"

Then I tried to edit an attribute of the new store with the following code:

$product = $this->_productRepository->getById(1,true,2);
$product->setName('Testproduct in store 2');
$this->_productRepository->save($product);

I expected this result:

Store 0 Name: "Testproduct"
Store 1 Name: Use default value
Store 2 Name: Use default value

Store 0 Description: "Test description"
Store 1 Description: Use default value
Store 2 Description: "Test description in store 2"

But I got this result:

Store 0 Name: "Testproduct"
Store 1 Name: "Testproduct in Store 2"
Store 2 Name: Use default value

Store 0 Description: "Test description"
Store 1 Description: "Test description in store 2"
Store 2 Description: "Test description in store 2"

And every other attribute in store 1 got copied from store 2.

@magento-engcom-team
Copy link
Contributor

Possible duplicate #7720

@magento-engcom-team
Copy link
Contributor

@ochnygosch, thank you for your report.
We've created internal ticket(s) MAGETWO-83254 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Nov 9, 2017
@versdivers
Copy link

versdivers commented Dec 26, 2017

Is there a quick fix for this? Experiencing this within Magento 2.2.1 when saving an a product trough the product repository for a store.

So i do set the StoreId but some attributes (not all and kind of random) are getting 'use default value' unchecked while not setting those.

Edit : This is not random. This is only on the attributes that have a default value

@magento-engcom-team
Copy link
Contributor

Closing, as this issue duplicates #7720

@t-heuser
Copy link

Love it. Just stumbled upon this issue. Using Magento 2.4.3 this is still an issue and it's definitly not a duplicate of #7720.

This issue should be reopened and the bug fixed. Maybe a new ticket should be raised but I'm really too tired of creating new issues here which are closed for completely bs reasons.

magento-devops-reposync-svc pushed a commit that referenced this issue Nov 10, 2022
B2B-2423: Optimize addProductsToCart operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants