Skip to content

Requesting products via REST API using store code in URL returns products from all stores #15461

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

Open
Vossie1975 opened this issue May 23, 2018 · 31 comments · May be fixed by #37903
Open

Requesting products via REST API using store code in URL returns products from all stores #15461

Vossie1975 opened this issue May 23, 2018 · 31 comments · May be fixed by #37903
Assignees
Labels
Area: APIs Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just 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 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@Vossie1975
Copy link

Vossie1975 commented May 23, 2018

Preconditions

  • Magento 2.4-develop;
  • Integration created;

Steps to reproduce

  1. Create a website with code wb2.

  2. Create a store st2 and assign it to the wb2 website.

  3. Create a store view with code sv2 and assign to the new store.
    image

  4. Create product and assign only to wb2 website.
    image

  5. Perform REST API GET request using the store code in the URL, eg:
    GET /rest/default/V1/products/?searchCriteria[currentPage]=10

Expected result

Only products assigned to the test website are returned (or no products if none assigned).

Actual result

All products in the Magento instance are returned.
image

@magento-engcom-team magento-engcom-team added Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels May 23, 2018
@ghost ghost self-assigned this Jul 11, 2018
@ghost
Copy link

ghost commented Jul 11, 2018

@Vossie1975, thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development 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 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 Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Jul 11, 2018
@ghost ghost removed their assignment Jul 12, 2018
@Vossie1975
Copy link
Author

any idea when this bug wil be fixed (again)?

@paul-blundell
Copy link

Typical Magento. Another major bug that is being left to gather dust...

@Tiberriver256
Copy link

Any update?

@Vossie1975
Copy link
Author

probably not....
Does not seem interesting for Magento to solve this.
This bug was previously in the system and would have been resolved then.
But is there again / still in it.
I have now reported this almost a year ago, but not a single update since that time.
Recently also other bugs found (in MSI function) but why would you still take the trouble to report it if nothing is done with it ....

@razza12
Copy link

razza12 commented May 20, 2019

Will this be resolved? Am still seeing this issue on 2.3.1

@Cyclonecode
Copy link

Cyclonecode commented Jun 20, 2019

I am running magento 2.2.6 and this is a huge problem for us right now. Is there anyway to workaround this?

@Vossie1975
Copy link
Author

dont think this will ever be fixed.
this is second time that this problem is in Magento and i have posted this more then a year ago and no response anymore in that time.
Only sollution (what we are also working on nowe) is to stop using magento.
We are building a new webshop now on other ecommerce software becouse of this problem.

@engcom-Charlie engcom-Charlie added the Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch label May 25, 2020
@engcom-Charlie engcom-Charlie self-assigned this May 25, 2020
@m2-assistant
Copy link

m2-assistant bot commented May 25, 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.
    1. 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!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

@mshifo
Copy link

mshifo commented Jul 28, 2020

are there any updates ?

@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Sep 23, 2020
@gabrieldagama gabrieldagama added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Sep 29, 2020
@Vossie1975
Copy link
Author

wowww after only 3 1/2 years already a response.....
but never mind, fortunately within 1 and 2 months finally got rid of magento and to completely different software!

@ihor-sviziev
Copy link
Contributor

@Vossie1975,
Sorry, I completely understand that your issue wasn't noticed for a huge amount of time.
I prefer re-opening this issue as it's still not fixed yet.

@ihor-sviziev ihor-sviziev reopened this Sep 15, 2021
@m2-community-project m2-community-project bot added Progress: ready for dev and removed 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 Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Progress: done labels Sep 15, 2021
@ihor-sviziev ihor-sviziev added 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 Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Sep 15, 2021
@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-1231

@tuyennn
Copy link
Member

tuyennn commented Mar 16, 2022

Is anyone working on this?

@invertedfjord
Copy link

I can confirm that the issue still reproducing on 2.4-develop branch.

  1. created website, store and store view:
    image
  2. created new root category and sub-category for 2nd store
    image
  3. created simple product, assigned to 2nd website:
    image
    image
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/products?searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8'

Expected result: Only one test product should be returned.

Actual result: ❌ Returned all products available in Magento image

Other notes:

  1. The same request with the filter applied using search criteria works fine (THIS IS WORKING WORKAROUND):
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/products?searchCriteria[filter_groups][0][filters][0][field]=store_id&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][0][value]=sv2&searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8' 

✔Only one test product is returned image

  1. Fetching categories works fine w/o applying filter using search criteria:
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/categories?searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8' \
--header 'Cookie: PHPSESSID=dbov1elserndboromibgi6sl0l'

✔ The only categories returned for 2nd store image

  1. Fetching categories works fine with applying filter using search criteria:
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/categories?searchCriteria[filter_groups][0][filters][0][field]=store_id&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][0][value]=sv2&searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8'

✔ The only categories returned for 2nd store image

I can confirm that the issue still reproducing on 2.4-develop branch.

  1. created website, store and store view:
    image
  2. created new root category and sub-category for 2nd store
    image
  3. created simple product, assigned to 2nd website:
    image
    image
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/products?searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8'

Expected result: Only one test product should be returned.

Actual result: ❌ Returned all products available in Magento image

Other notes:

  1. The same request with the filter applied using search criteria works fine (THIS IS WORKING WORKAROUND):
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/products?searchCriteria[filter_groups][0][filters][0][field]=store_id&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][0][value]=sv2&searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8' 

✔Only one test product is returned image

  1. Fetching categories works fine w/o applying filter using search criteria:
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/categories?searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8' \
--header 'Cookie: PHPSESSID=dbov1elserndboromibgi6sl0l'

✔ The only categories returned for 2nd store image

  1. Fetching categories works fine with applying filter using search criteria:
curl --location -g --request GET 'https://a157f32be171e2a736d57b2a1dece736-2-4-develop.instances.magento-community.engineering/index.php/rest/sv2/V1/categories?searchCriteria[filter_groups][0][filters][0][field]=store_id&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][0][value]=sv2&searchCriteria[pageSize]=50&searchCriteria[currentPage]=1' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjMxNzA2ODQyLCJleHAiOjE2MzE3MTA0NDJ9.y38aigVekrNE5KkogtWAUf3jtLRzj0H_aRfViJcWKp8'

✔ The only categories returned for 2nd store image

@ihor-sviziev Does this workaround that you mentioned query the DB in the same way?

@hugocore
Copy link

For those reading and following this issue, there's a workaround:

https://<DOMAIN>/rest/<STORE_CODE>/V1/products?
searchCriteria=&
searchCriteria[filterGroups][0][filters][0][field]=store_id&
searchCriteria[filterGroups][0][filters][0][value]=<STORE_CODE> 

Essentially you can scope products by a store if you pass the store code as a custom search criteria.

@invertedfjord
Copy link

For those reading and following this issue, there's a workaround:

https://<DOMAIN>/rest/<STORE_CODE>/V1/products?
searchCriteria=&
searchCriteria[filterGroups][0][filters][0][field]=store_id&
searchCriteria[filterGroups][0][filters][0][value]=<STORE_CODE> 

Essentially you can scope products by a store if you pass the store code as a custom search criteria.

We did extensive testing and passing the store code as a search param does not work reliably. If you pass the store ID for products it does work most of the time.

Testing on many Magento 2 accounts on various versions came to the following results.

  1. Store code in the URL is essentially useless.
  2. Store ID passed as a search param does work for 80% of accounts. Some accounts return 500 or 400 errors and sometimes it's still not store scoped. (Not sure why maybe from some customizations on the store front)

@howdyravi
Copy link

howdyravi commented May 15, 2023

Any update on this ?

@nidhigupta13-ey
Copy link
Contributor

@magento I am working on this

@nidhigupta13-ey nidhigupta13-ey linked a pull request Aug 21, 2023 that will close this issue
5 tasks
@engcom-Bravo engcom-Bravo removed the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Apr 30, 2024
@engcom-Hotel engcom-Hotel moved this to Dev In Progress in High Priority Backlog Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: APIs Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just 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 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging a pull request may close this issue.