Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.
SOLVED

Is it possible to use an argument other than skus with the GET_PRODUCT_DATA query in Catalog Service on EDS Storefront?

Avatar

Level 4

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!

1 Accepted Solution

Avatar

Correct answer by
Level 4

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
            }
          }
        }
      }

 

View solution in original post

4 Replies

Avatar

Community Advisor

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

Avatar

Level 4

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

Avatar

Administrator

@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.



Kautuk Sahni

Avatar

Correct answer by
Level 4

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
            }
          }
        }
      }