Headless commerce and custom storefronts with Shopify APIs and SDKs
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?
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
}
}
}
}
}
}
}
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023