FROM CACHE - en_header

Query for all InventoryItems associated with a product/variant

Solved
anonymous1
Excursionist
19 3 14

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!

Accepted Solution (1)

Accepted Solutions
Greg_Kujawa
Shopify Partner
1023 84 268

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

View solution in original post

Replies 3 (3)
Greg_Kujawa
Shopify Partner
1023 84 268

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

anonymous1
Excursionist
19 3 14

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?

Greg_Kujawa
Shopify Partner
1023 84 268

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?