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
}
}
}
}
}
}
}
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022