Return management just got easier! We’ve launched Customer Self-Serve Returns to all Shopify merchants. Click here to learn more!
Some merchants and partners are experiencing problems when logging into their Shopify accounts. We will continue to provide updates to you here.

How to get a product by SKU via StoreFront API?

mmarienko
Shopify Partner
6 0 3

I need to get a product by SKU via StoreFront API, but that is impossible for me. I didn't find any information about that on the Shopify dev doc. I found only GraphQL filter by SKU, but it is not available for StoreFront, only for Admin API. 
Is there another way?

Reply 1 (1)
adrocodes
Shopify Partner
1 0 0

Hey Marienko,

 

You can access the SKU through the storefront API, they are just tied to a Product Variant. Even if you don't add a variant to a product, there will always be at least one with the SKU that has been entered. (In the returned data, the title is usually "Default Title", if you haven't added a product variant)

 

If your products do have variants, then the SKU will change based on the selected SKU.

 

Hopefully that helps. Here is an example GraphQL Query:

{
  products(first:10){
    edges{
      node{
        id
        variants(first:100) {
          edges {
            node {
              sku
              title
            }
          }
        }
      }
    }
  }
}