Query for all InventoryItems associated with a product/variant

Solved
anonymous1
Excursionist
17 3 9

Hi all,

I am looking for a way to do what I think is a very simple thing: query the API for all InventoryItem objects associated with a Product/Variant.  Something like admin/products/{product_id}/inventory_items.json.

The reason is because I've programmatically duplicated some inventory items and now need to run a cleanup script to prune the redundant InventoryItems.

Thanks!

0 Likes
Greg_Kujawa
Shopify Partner
963 80 204

This is an accepted solution.

While I'm not sure of the REST API request off the top of my head, the GraphQL API request is pretty basic. See screen shot below!

Untitled.png

0 Likes
anonymous1
Excursionist
17 3 9

Hey thanks a lot!  There is no mention of this functionality in the REST docs.  Is there a way to DELETE InventoryItems via the GraphQL interface?

0 Likes
Greg_Kujawa
Shopify Partner
963 80 204

There does appear to be a GQL mutation where you can adjust quantity --> https://shopify.dev/docs/admin-api/graphql/reference/inventory/inventoryadjustquantity. Zeroing out an inventoryItem should accomplish what you're looking for, right?

0 Likes