Skip to content

REST API: Product updates with wrong store_id #7612

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

Closed
tdittmar opened this issue Nov 29, 2016 · 10 comments
Closed

REST API: Product updates with wrong store_id #7612

tdittmar opened this issue Nov 29, 2016 · 10 comments
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@tdittmar
Copy link

tdittmar commented Nov 29, 2016

Preconditions

  1. Magento 2.1.2 out of the box installation
  2. An application that communicates via REST API with that Magento installation

Steps to reproduce

  1. Create a new simple item via REST API (POST to /rest/V1/products) with descriptions and META information.
  2. Verify in shop bakend that the item was created correctly.
  3. Verify in database (table catalog_product_entity_text) that the attributes are inserted with store_id 0
  4. Update the long description for that same item via REST API (PUT to /rest/V1/products/{sku}).
  5. Check the shop backend: the long description appears to be unchanged
  6. Check the database (same table): A new attribute is inserted with store_id 1 instead of updating the previously created attribute.

Expected result

  1. The description that was created when creating the item should be changed when updating the item instead of creating a new attribute with the wrong store_id.

Actual result

  1. The description that was created when creating the item still exists, but a new description is added with a wrong store_id 1.

This is for Magento version 2.1.2 and was not an issue in pre-2.1 versions.

@veloraven
Copy link
Contributor

@tdittmar thank you for your feedback.
Please, format this issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.

@tdittmar
Copy link
Author

tdittmar commented Nov 30, 2016

@veloraven I updated the original bug report.

@veloraven veloraven added 2.1.x bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog and removed Progress: needs update labels Nov 30, 2016
@tdittmar
Copy link
Author

By the way: The same problem occurs also when fetching product information from Magento with a GET request to /rest/V1/products/{sku}. I get the wrongly inserted new product attributes by default.

Only if I delete the wrongly inserted attributes from the database manually I get the expected values that were passed to Magento when creating the item.

@olysenko olysenko self-assigned this Dec 2, 2016
@olysenko
Copy link

olysenko commented Dec 5, 2016

Hi, thank you for your report. Internal ticket MAGETWO-61834 was created

@olysenko olysenko added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed in progress labels Dec 5, 2016
@olysenko olysenko removed their assignment Dec 5, 2016
@Silarn
Copy link

Silarn commented Dec 7, 2016

The problem (with saving, anyway) is that there's no way to configure which store scope to use with the current API code.

Line 513 of \Magento\Catalog\Model\ProductRepository in save():
$productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();

Magento always just gets the current frontend store_id when saving the product data. There's no way to pass in the desired store - or to set the global store data.

@tdittmar
Copy link
Author

tdittmar commented Dec 7, 2016 via email

@Silarn
Copy link

Silarn commented Dec 7, 2016

Not completely clear. Both methods resolve to the same save() function, but there are slightly different methods called if it's a new product. (Both methods can update existing products, and POST has the same issue when updating products.) Perhaps the data for a new product is just being saved globally instead of for a specific scope, which could be a different bug in itself. Most likely this could be because there has to be data for the global scope so new data gets saved there while updated data may write to a store-specific scope if the store_id is set.

@careys7
Copy link
Member

careys7 commented Feb 20, 2017

Is there any progress on a fix for this Magento / @olysenko ?

No multi-store catalog API is a problem for most of our clients (see also #8121 / #4806 which has been open for 8 months).

@veloraven
Copy link
Contributor

I'm closing this issue as internal ticket was closed as not a bug.

For update Product or Category on Global Scope we should set Store Code = all.
For example http:///index.php/rest/all/V1/categories/:id or http:///index.php/rest/all/V1/products/:sku
This point described in http://devdocs.magento.com/guides/v2.0/rest/rest_endpoints.html

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Jun 3, 2020

Still a problem in Magento 2.2, 2.3.

magento-devops-reposync-svc pushed a commit that referenced this issue May 24, 2022
CABPI-4: IMS identity | Adobe Commerce Core Admin Panel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

6 participants