2

The store is composed of different websites with multiple stores and multiple storeviews.

I'm developing a functionality to get the particular storeview depending on the location of the customer and get its product catalog with prices.

But when I go to get the information from the current store I am always in the default store using GraphQL query,

  • How could I get the information from any other store or set values in a different store?

  • Is there a GraphQl query or can I make a request to the Rest API to change store to get the products from a store using the store id or store code?

3 Answers 3

5

GraphQL request accepts the Store into headers.

Header Key : Store

Header Value : <store_view_code>

The store view code on which to perform the request. The value can be default or the code that is defined when a store view is created.

enter image description here

I recommend you to use Altair GraphQL Client

For More Header click Here

I Hope This Helps You.

2
  • Not sure why they can't do this in the code, 2.4.4 still has this problem
    – David Tay
    Aug 31 at 16:37
  • @DavidTay If you need it so please rise issue in Magento github.
    – Msquare
    Aug 31 at 17:31
3

For Storewise Graphql queries you need to add a variable in HEADER just like AUTHORIZATION in Magento 2 . The Header for Store wise data is

Store:

for more Information you can check https://devdocs.magento.com/guides/v2.3/graphql/send-request.html#headers

0

I had a setup where one magento backend was used for two magento websites each with at least a store and a store_view. For me it was loading the same default store even though I had changed the MAGENTO_BACKEND_URL value.

In order to fix that I had to add the required STORE_VIEW_CODE in .env file under venia-concept in order to load the desired store.

For more information

https://magento.github.io/pwa-studio/pwa-buildpack/reference/environment-variables/core-definitions/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.