How we can search product variants by SKU number

Solved
Highlighted
New Member
9 0 0

Hello,

How we can search product variants by SKU number.

We have had issues with our API connection, I have tried many things from the docs and nothing works and this is the whole problem here because sometimes when script wants to delete duplicated products it's not working since to delete a products ID must be sent to API, and script is sending SKU instead.

When I want to delete a product on shopify I need that product id, but I don't have it. I have only sku and I need to find product id by product sku.

Is that possible?

Not sure if I am explaining myself.

Full discloser: I am not the developer, I am the Shopify Store owner asking the question on his behalf.

Thank you for the help.

0 Likes
Highlighted
Tourist
6 1 0

This is an accepted solution.

A product is a collection of variants.Each variant has an sku field. Your script (if its yours u didnt explain) can extract the product id from the variant the same way as it did for the sku. But why u need to delete all variants (because that will happen if u delete by using product id).maybe u want to delete the variant with sku u found?  again am only guessing here because i dont understand what u want to do. 

maybe explain what u trying to solve.

so if you want the product that one of its variants has the sku u have then u should get all products then search each variant of each product to find what u looking for

0 Likes
Highlighted
New Member
9 0 0

I want to get product_id field based on sku field in "variants" collection

if I do this through script it will be very slow at the end. To understand better this is the flow:

Image Pasted at 2020-6-10 10-32.jpgFetch one product from BTS> check if exists > if true get the list of ALL variants > filter ALL variants (can be 200, 500, 1000 of them) by SKU number > return ONE variant based on ("Fetch one product from BTS" sku number) > delete that product

repeat this for each product

if I can delete product by SKU number that would be much more helpful

Thank you

0 Likes
Highlighted
New Member
9 0 0

I want to get product_id field based on sku field in "variants" collection

Image Pasted at 2020-6-10 10-32.png
 

if I do this through script it will be very slow at the end. To understand better this is the flow:

Fetch one product from BTS> check if exists > if true get the list of ALL variants > filter ALL variants (can be 200, 500, 1000 of them) by SKU number > return ONE variant based on ("Fetch one product from BTS" sku number) > delete that product

 

repeat this for each product

 

if I can delete product by SKU number that would be much more helpful

0 Likes
Highlighted
Tourist
6 1 0

if you can return a variant u have the product id that it belongs to.

0 Likes
Highlighted
New Member
9 0 0

I need to return variant by SKU number

0 Likes
Highlighted
New Member
9 0 0

Please can anyone help on this?

I need to return variant by SKU number

0 Likes