Hi Adobe Community,
In my Storefront implementation, I see that the GET_PRODUCT_DATA GraphQL query for Catalog Service is defined as follows:
query GET_PRODUCT_DATA($skus: [String]) {
products(skus: $skus) {
...ProductFragment
}
}
Is it possible to use a different argument (urlKey) instead of skus to fetch product data? If not, what is the recommended approach to support product lookups by other identifiers—should I implement a proxy or is there a built-in way to extend the query?
Thank you for your help!
Solved! Go to Solution.
Views
Replies
Total Likes
hi @kautuk_sahni ,
In my project it worked as follow:
query productSearch($urlKey: String!) {
productSearch(
phrase: ""
filter: {attribute: "url_key", eq: $urlKey}
) {
total_count
items {
product {
sku
}
}
}
}
HI @olsalas711 ,
Magento’s GraphQL API does not accept urlKey
(or other identifiers) as a top-level argument like skus, but it does support filter parameters in the products query.
query GET_PRODUCT_BY_URLKEY($urlKey: String!) {
products(filter: { url_key: { eq: $urlKey } }) {
items {
...ProductFragment
}
}
}
-Tarun
Hi @TarunKumar ,
Thanks for your response.
Just to confirm—does the same apply to the Catalog Service as well, for example in productSearch?
Best regards,
Oscar
Views
Replies
Total Likes
@olsalas711 Did you find the suggestion helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.
Views
Replies
Total Likes
hi @kautuk_sahni ,
In my project it worked as follow:
query productSearch($urlKey: String!) {
productSearch(
phrase: ""
filter: {attribute: "url_key", eq: $urlKey}
) {
total_count
items {
product {
sku
}
}
}
}
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies