Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: GraphQL BulkOperation to Update Inventory Quantities

GraphQL BulkOperation to Update Inventory Quantities

luke-csg
Tourist
4 0 13

Hi,

 

Shopify is not our primary inventory and stock management system. I am trying to setup a GraphQL BulkOperationMutation to update stock available on our Shopify Shops for various locations.

 

Previously we were using the REST API and pagination to do this synchronously but with so many products and multiple locations this is failing a lot due to throttling and timeout issues.

 

I thought I had it sorted with a BulkOperation ProductVariantsBulkInput but inventoryQuantities only seem to be supported on Create and not Updates.

 

I have found I can update Inventory Stock levels via the GraphQL inventorySetOnHandQuantities but this doesn't appear to be supported for bulk operations.

 

Can anyone tell me if it is possible to bulk update stock inventory quantities?

 

Thanks,

 

Luke

Replies 14 (14)

ShopifyDevSup
Shopify Staff
1453 238 518

Hey @luke-csg - thanks for getting in touch. You are correct that the inventorySetOnHandQuantities mutation isn't supported with Bulk Operations (list of all supported mutations here). 

I was also able to do some testing on our end here and can confirm that inventory quantities can't be updated using the Product Variants as you mentioned, however you should be able to update the quantities for multiple inventory items using the inventoryItemAdjustQuantities mutation. 
 

For example:

mutation AdjustMultipleInventoryQuantities($input: InventoryAdjustQuantitiesInput!) {
 inventoryAdjustQuantities(input: $input) {
   userErrors {
     field
     message
   }
   inventoryAdjustmentGroup {
     createdAt
     reason
     referenceDocumentUri
     changes {
       name
       delta
     }
   }
 }
}
 

and the variable inputs:

{
 "input": {
   "reason": "correction",
   "name": "available",
   "referenceDocumentUri": "logistics://my.warehouse/take/2023-01/13",
   "changes": [
     {
       "delta": -4,
       "inventoryItemId": "gid://shopify/InventoryItem/12345678",
       "locationId": "gid://shopify/Location/12345678"
     },
     {
       "delta": 5,
       "inventoryItemId": "gid://shopify/InventoryItem/12345678",
       "locationId": "gid://shopify/Location/12345678"
     }
   ]
 }
}

Hope this helps - let us know if we can clarify anything further on our end here. 

 

Al | Shopify Developer Support 
 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

luke-csg
Tourist
4 0 13

Thanks for the feedback.

 

This issue with using a delta for me is that we aren't keeping track on the Shopify stock quantities. Stock management is controlled through our own platform. I would need to query the Shopify API to establish what the current stock available level is for each product variant and compare to our stock system to calculate the delta to apply. 

 

Whilst that is possible it complicates and slows down the process when the ability to simply set the quantity would do the job.

 

Plus with asynchronous Bulk Operations having a longer run time its possible an order could be placed and change the available quantity between querying the available quantity and the delta mutation to amend the quantity.

 

Actually I can't see inventoryAdjustQuantities listed as supported for Bulk Operations? Can you confirm it is supported?

ShopifyDevSup
Shopify Staff
1453 238 518

Hey @luke-csg,

 

I can confirm that inventoryAdjustQuantities is not a supported Bulk Operation and the suggested work around is just a method to make multiple inventory adjustments using the mutation.

 

Hope that helps! 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

luke-csg
Tourist
4 0 13

Ok. Certainly the GraphQL inventoryAdjustQuantities mutation is an improvement on the REST Admin API as this allows up to 250 inputs per query.

 

I hit an issue where some InventoryItems not being activated for some locations. I am activating these using the inventoryBulkToggleActivation mutation. However, whilst I can activate multiple locations per InventoryItem, I only seem be able to activate one InventoryItem per query. Are there any mutations that support activating multiple InventoryItems with locations per query?

 

It's slow going 1 at a time for 1000's of inventory items.

ShopifyDevSup
Shopify Staff
1453 238 518

Hey @luke-csg - at the moment there isn't a mutation that would support activating multiple InventoryItems, the current workaround you mentioned is the best way to do this right now our recommendation would be to call inventoryBulkToggleActivation in a loop for each inventory item. I definitely understand it's not the most ideal workaround though. I'm going to put through a report on my end here so that we can forward on this thread to our developers for future consideration in terms of implementing a feature like the one we're discussing here. 

I can't guarantee anything going forward (including a response) - but I can confirm we'll get product team eyes on this. As always - hope this helps!

 

Al | Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

luke-csg
Tourist
4 0 13

Thanks for the feedback.

 

I now have everything working and it's much more robust that the previous REST API based solution we were using.

 

I do think it would be useful to have Bulk Operation for Inventory Quantity updates.

SIG_KAP
Shopify Partner
8 0 5

+1 
I too would benifit to have this included in the bulkOperation. 

collegeofcreati
Shopify Partner
1 0 1

Same here, is there any progress on this?

plesoiucosmin
Shopify Partner
1 0 1

I have opened a new github issue regarding this matter and hopefully we will soon get to bulk update/activate/deactivate inventories per location

AlexMinza
Shopify Partner
15 0 5

@ShopifyDevSup not having batch/bulk operations support in the GraphQL API for such common use cases is a MAJOR oversight from the technical/product team.

 

We are also affected by this shortsightedness of the Shopify team in our effort to build automated stock update flows with our suppliers with catalogs pf hundreds of thousands of products.

 

It’s been more than a year since this issue was reported in this thread - are there any updates from Shopify regarding this?

ShopifyDevSup
Shopify Staff
1453 238 518

Hi All,

 

Thanks for your continued feedback on this issue, we have added more details to the report about the desire for inventory updates as a bulk operation.

 

One thing to consider is that inventory updates generally need to happen very quickly and a large bulk operation can take an amount of time to go through. If a busy shop is running a tight inventory margin and an inventory adjustment is slow to process due to being in a large bulk op that could have an impact on the shop. 

 

So keeping them small does help to keep them fast and timely. That said, we appreciate your valuable feedback that there's a desire for being able to update more inventory with fewer API calls.

 

Thanks and hope you have a great day

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

MISEASD
Shopify Partner
6 0 9

Bump to this. Looking bulkoperation for inventory quantities also

AlexMinza
Shopify Partner
15 0 5

The irony is that you can activate/inactivate in bulk via manual import stock CSV https://help.shopify.com/en/manual/products/inventory/getting-started-with-inventory/inventory-csv

 

  • activate - set numeric stock level
  • inactivate - set stock level to literal string "not stocked"

The number that you enter in each row can be positive, negative, or 0. You can also enter not stocked to indicate that the product is never stocked at the location.

 

https://community.shopify.com/c/fulfillment-and-inventory/inventoryactivate-in-bulk-mode/m-p/2651953...