Query Product Variants directly and filter by SKUs

Solved

Query Product Variants directly and filter by SKUs

marbor3
Shopify Partner
2 0 0

Hi! 

 

We're integrating now existing Shopify store into one of our applications that already has some product info in there. 

What we need is to match our products with the ones in existing Shopify store.
What we can use to match those is the SKU of a variant.

 

Is there a way to query this directly using Storefront API?

 

So far my best guess is not, but answers are from few years back: https://community.shopify.com/c/products-variants-and/could-i-query-a-productvariant-by-id-of-the-va...


maybe something changed in the meantime and it's possible now?

 

Thanks a lot!

Accepted Solution (1)

SBD_
Shopify Staff
1829 272 417

This is an accepted solution.

Hey @marbor3 

 

If I'm understanding correctly you want to look up a product by SKU? Right now that's not possible with the Storefront API but it is possible with the Admin API. Depending on the number of products it could be worth using the Admin API to create a map.

 

{
  productVariants(first: 10, query: "sku:ABC12345") {
    nodes {
      id
    }
  }
}

 

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 2 (2)

SBD_
Shopify Staff
1829 272 417

This is an accepted solution.

Hey @marbor3 

 

If I'm understanding correctly you want to look up a product by SKU? Right now that's not possible with the Storefront API but it is possible with the Admin API. Depending on the number of products it could be worth using the Admin API to create a map.

 

{
  productVariants(first: 10, query: "sku:ABC12345") {
    nodes {
      id
    }
  }
}

 

Scott | Developer Advocate @ Shopify 

marbor3
Shopify Partner
2 0 0

Hi @SBD_ 

 

Yes, that's it. Thank you. I was afraid it's that. Ok, maybe we'll create map then.