Need to return variant by SKU number

New Member
9 0 0


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.

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

I need to return variant by SKU number

Thank you