Solved

Fetching also translations with Storefront API Graphql Endpoint

ptrck_schndr
Shopify Partner
9 0 10

We are using the Storefront API to fetch more than 50 products at once on the Products QueryRoot Object with an array of IDs. This runs very smooth and fast, so no problem here. We have also translated product data with the Admin Translation API by a self-made custom app which fetches products from an ERP automatically. Runs smooth too, so there is also no problem here.

BUT – if we use the i18n language codes to switch the translations in the URL, e.g. from https://supershop.com to https://supershop.com/fr and then using the /api/graphl endpoint, it still gives us the standard language data from the product and NOT the translated french language data.

Is there any possibility that the endpoint recognizes that I am doing my request from a translated shop url?

Accepted Solution (1)

c10s
Shopify Partner
67 12 25

This is an accepted solution.

Replies 4 (4)

c10s
Shopify Partner
67 12 25

This is an accepted solution.

Try adding an Accept-Language header to the request, as documented here: https://shopify.dev/tutorials/support-multiple-languages-with-storefront-api#retrieving-storefront-a...

ptrck_schndr
Shopify Partner
9 0 10

Thanks, this did the trick!

pierrealexis
Visitor
3 0 0

This solution doesn't work anymore since the documentation have changed 

For me event after getting multiples languages with localization none of them work if I use @inContext(language: ES) for exemple

mfirghi
Shopify Partner
4 0 0

Any update on this? it is still not working for me