Get inventoryItems for multiple products

Highlighted
Excursionist
40 1 6

What is the best way to get the inventory levels for multiple products?

I can use the mutation inventoryItems to get all products in a store (25,000), but what if I just want to get say 1000 of them.  I can query them individually, but is there a more efficient way, like an array of say 100 that I could then batch up

Thanks

Grant

0 Likes
Highlighted
Shopify Partner
539 38 110

Would the subset have anything in common? For example, having the same tag, being part of the same collection, etc. If there is some commonality then you could query based on that, right?

0 Likes
Highlighted
Excursionist
40 1 6

Unfortunately not.  They will be a list of skus where stock has changed.  From that I will then get the inventory level, either directly or from its inventory ID that I have stored

I have see this sort of thing: #https://community.shopify.com/c/Shopify-APIs-SDKs/Graphql-query-help-get-stock-for-1-SKU-for-1-locat...

But really wanted something where I could pass in an array of values or something

Thanks

Grant

 

0 Likes
Highlighted
Shopify Partner
539 38 110

If you subscribe to the product variant's inventory level changed webhook then you can act off those as they occur. Of course your triggered API requests would be serially made, but then again they would be closer to real-time than trying to batch an array of items based on stock levels changing. Does this make sense?

0 Likes
Highlighted
Excursionist
40 1 6

Interesting.  So that would tell me what has changed, I could then act on that.

Probably wont help me here though as I need to base my changes on what has changed in our global stock file.  For example for a sku we sell 100 products through a different channel, I then need to update that product inventory level (which may not have been sold through the website)

Thanks

Grant

0 Likes
Highlighted
Shopify Partner
539 38 110

As long as the sales channel is listed on Shopify then any product inventory level change should fire off the webhook request. So I don't foresee there being an issue getting the messages that you can then handle as the trigger is fired off!

0 Likes