Find Product/Variant by SKU value.

Shopify Partner
3 0 0

I currently store references to SKUs in my own db so I can track my inventory across multiple sales channels, Shopify included.

When I want to update inventory via the Shopify JSON API, I have to pass in a Shopify product ID (rather than my SKU value).

Consequently, I can't seem to find a way to search for a product by its variants' SKU value, and update the stock accordingly. This is supported everywhere else in eBay/ Magento/ Amazon and so forth; Is this functionality supported in the Shopify API (bearing in mind I can search from the product screen by SKU), and what does the API call look like?

Thanks, Ian.

 

0 Likes
Shopify Staff
Shopify Staff
591 0 45

In Shopify skus aren't forced to be unique so searching for a single product based on sku wouldn't work in the same way it would at the other providers.

That being said, it appears that the search API that is used by the admin is open and you can leverage that to find the products you are looking for:

curl -H "Content-Type: application/json" \
https://user:pass@yourshop.myshopify.com/admin/products/search.json?query=sku:abracadabra

 

3 Likes
Shopify Partner
3 0 0

Appreciate the response Chris, will check it out. I think it's a bit strange that this isn't inherently supported in the API as it would make sense for a lot of sellers, and returning a list of matched variants would be fine. I think it's down to the seller to make a good choice in SKU naming rather than the marketplace, so not enforcing 'uniqueness' makes sense to me anyway.

0 Likes
Shopify Partner
3 0 0

That works nicely, thanks. Also tried it with the OAuth token which also works fine.

Thanks for your help!

0 Likes
Highlighted
New Member
2 0 0

This is not working against the PUT request. It shows error "{'errors': {'id': 'expected String to be a id'}}". Could you help me with this.

0 Likes