We’re working on processing translations using the translatableResources API. For products, it’s straightforward - Shopify returns the resourceId like this:
However, we’re unsure how to associate translation entries like METAFIELD, PRODUCT_OPTION, and PRODUCT_OPTION_VALUE with their parent product (or other entities).
Hey @MasterDev you’re right that this is a bit tricky. I did a bit of testing on my end, and it would depend on what type of integration you’re building, but you could build a function at code level that would run something like this to grab the translatableResources:
query GetProductOptions {
translatableResources(first: 10, resourceType: PRODUCT_OPTION) {
edges {
node {
resourceId # This is the ProductOption ID
translatableContent {
key
value
digest
locale
}
}
}
}
}
The resource ID that’s returned would be the product option ID. You could then run something like this to get the option value:
query GetProductFromOption($optionId: ID!) {
node(id: $optionId) {
... on ProductOption {
id
name
values
optionValues {
id
name
hasVariants
}
}
}
}
Finally, you could then run a query using the plaintext option value itself to get the product info:
query GetProductFromOptionValue {
productVariants(first: 10, query: "option1:'[option-value-here-without-brackets]'") {
edges {
node {
id
selectedOptions {
name
value
}
product {
id
title
options {
id
name
values
}
}
}
}
}
}
Then, to double check that you’ve pulled the right parent product, you could compare the optionValue GID string from the one that was original output.
It’s definitely not the most ideal workflow though and it may not work for metafields in the same way. Translated resources are generally intended for apps that manage just the translation of those texts though, so generally the full context of the resource isn’t usually needed.
Just out of curiosity, could you let me know why you’re looking at pulling the parent products, etc? I’m definitely happy to see if I can help with some other workarounds or set up a feature request for sure!