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

Product Repository saves attribute values for existing product always on "Default Store Level" #7720

Closed
itaymesh opened this issue Dec 7, 2016 · 21 comments
Assignees
Labels
bug report Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.4.x The issue has been fixed in 2.4-develop branch 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 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.

Comments

@itaymesh
Copy link
Contributor

itaymesh commented Dec 7, 2016

Preconditions

  1. Magento 2.1.2
  2. PHP 7
  3. Mysql 5.6

Steps to reproduce

  1. Create a CLI command to create/update a production
  2. Execute the comment (new product)
  3. Execute the comment (update product)

Expected result

  1. New Product: values are saved on "All Store Views"
  2. Update Product: values are saved on "All Store Views"

Actual result

  1. New Product: values are saved on "All Store Views"
  2. Update Product: values are saved on "Default Store View"

Seems like the product repository class overrides the product store id and always assign default store id

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

$productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();

The only way to work around this issue is by getting the existing product with explicit parameter:
$product = $this->_productRepository->get($sku, true, 0);

and use the deprecated save method of Magento\Framework\Model\AbstractModel class at line 629.

@itaymesh itaymesh changed the title Product Repository save action for exisiting product save values on default store level Product Repository saves exisiting product attribute values on "Default Store Level" Dec 7, 2016
@itaymesh itaymesh changed the title Product Repository saves exisiting product attribute values on "Default Store Level" Product Repository saves attribute values for existing product always on "Default Store Level" Dec 7, 2016
@mattcoz
Copy link

mattcoz commented Mar 16, 2017

This is driving me crazy. Updating a product in the backend always saves attributes with store_id of 0 and then on the frontend it looks up attributes using store_id of 1. So the only way to update anything is to do so directly in the database. This is with single store mode enabled, which should mean that there should only be ONE store not two.

@leitot
Copy link

leitot commented Mar 27, 2017

I have this issue as well. I fixed it with a hack but is something going to be done about this?

@p3mbo
Copy link

p3mbo commented May 22, 2017

I can confirm that this is an issue for me too still. Magento 2.1.6

@mattcoz
Copy link

mattcoz commented May 23, 2017 via email

@leitot
Copy link

leitot commented May 23, 2017

I wrote a before plugin for the save() method for the type Magento\Catalog\Model\ResourceModel\Product. Inside beforeSave() I set the store ID correctly on the product (after the ProductRepository's save() method messes it up)

@mattcoz
Copy link

mattcoz commented May 23, 2017 via email

@cherreman
Copy link

I have this issue in CE 2.1.7.

The save method in the ProductRepository is incorrectly setting the store_id property on the product.

The fix is to check if the store_id is already set on the product, and if not, set it. Add the if-statement around the line below:

if (!isset($productDataArray['store_id'])) {
    $productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();
}

@magento-engcom-team magento-engcom-team added 2.1.x bug report Component: Catalog Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@itaymesh, 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 3, 2017
@p-bystritsky p-bystritsky self-assigned this Dec 5, 2017
@engcom-Charlie engcom-Charlie added the Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch label Jan 16, 2020
@ghost ghost unassigned engcom-Charlie Jan 16, 2020
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-30488 were created

Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jan 16, 2020
@engcom-Charlie engcom-Charlie self-assigned this Jan 21, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jan 21, 2020

Hi @engcom-Charlie. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


engcom-Charlie pushed a commit to engcom-Charlie/magento2 that referenced this issue Jan 21, 2020
engcom-Charlie pushed a commit to engcom-Charlie/magento2 that referenced this issue Jan 27, 2020
engcom-Charlie added a commit to engcom-Charlie/magento2 that referenced this issue Feb 10, 2020
engcom-Charlie added a commit to engcom-Charlie/magento2 that referenced this issue Feb 10, 2020
@magento-engcom-team magento-engcom-team added this to PR In Progress in Community Backlog Mar 24, 2020
@VladimirZaets VladimirZaets added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Jun 17, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@m2-community-project m2-community-project bot moved this from Ready for Grooming to Pull Request In Progress in Low Priority Backlog Sep 3, 2020
@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: PR in progress labels Sep 3, 2020
@magento-engcom-team magento-engcom-team added Progress: ready for dev and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 17, 2020
@ghost ghost moved this from PR In Progress to Ready for Dev in Community Backlog Sep 17, 2020
@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Sep 18, 2020
@ghost ghost moved this from Ready for Dev to Done (last 30 days) in Community Backlog Sep 18, 2020
magento-devops-reposync-svc pushed a commit that referenced this issue Aug 10, 2022
B2B-2248: WebAPIAsync missing store information when db queue is used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.4.x The issue has been fixed in 2.4-develop branch 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 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
No open projects
Community Backlog
  
Done (last 30 days)
Development

No branches or pull requests