Focusing on managing products, variants, and collections through the API.
Hi, I wanted to get the translated Name of a productvariant using the 2024-04 version of the GraphQL api, so I used this request:
{
productVariants(first: 1, query: "updated_at:>'2023-10-31T13:30:24Z'") {
nodes {
product {
translations(locale: "en") {
value
}
title
}
translations(locale: "en") {
value
}
displayName
}
}
}
And when a variant has more than one option, the first one is not returned, as shown in the images below.
And I don't know why, but I have an HTML element returned to the value of the product title translation.
I don't know if it's a user problem or if it's coming from your side?
I also wanted to know if there was any way to get all the translations of every languages of a product variant, or at least do something like this:
translations(locale: "en AND fr") {
Solved! Go to the solution
This is an accepted solution.
Hey @Nolan_V , sorry for the delay in getting back to you here.
If it's still not returning all of the translated fields, I'd recommend reaching out to our support teams directly so we can take a closer look at the store details and see if we can replicate.
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey @Nolan_V ,
Thanks for sharing your query and the screenshots.
For the first question, with the first one not returned, what I would recommend here is to add in the id field as well as key fields. This way you'll be able to confirm the exact variant that is being returned and the specific field that corresponds with what value is being returned.
For the second question with not knowing where that html text is coming from, adding in the key field as well should help clarify that. Since that is a product translation then it's most likely the translated html of the product description.
For getting multiple languages in a single query, you can add multiple request. Using an Alias in your query will help here.
Here's an example query addressing the points above!
{
productVariants(first: 1) {
nodes {
id
German: translations(locale: "de") {
key
value
}
French: translations(locale: "fr") {
key
value
}
displayName
}
}
}
Hope that helps,
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @ShopifyDevSup, Thank you for your response.
I added the ID and key fields, and I can confirm that the first option is not getting returned by the API. Here are the full request and the result:
REQUEST :
RESULT :
Up
Hi, I did not found a solution for this issue
This is an accepted solution.
Hey @Nolan_V , sorry for the delay in getting back to you here.
If it's still not returning all of the translated fields, I'd recommend reaching out to our support teams directly so we can take a closer look at the store details and see if we can replicate.
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog