Scenario:
with my Nodejs app I connect to a courier FTP server to download a stock balance file two times a day. This file contains up to 30 thousands lines of text, each line is a product variant with unique SKU and available quantity. While downloading I use stream to convert data to a JavaScript object which result a list of arrays into array [["SKU",0]].
For your better understand this explanation, I will call this data: "source".
As you see we do not have inventoryItemId yet. So the idea is to:
1. queryGetInventoryItems();
create a query to get all inventoryItems id, sku and tracked status with something like this https://pastebin.com/KQzHcuiy and maybe repeat this until "hasNextPage": false, so to get all inventoryItems from the shopify store into our memory and then return all id, sku and tracked status into a shopifyInventoryItems.JSON file. Is this the right way to get all inventory items?
2. mutationInventoryItemUpdateToTracked();
sometime inventoryItem does result "tracked": false, to solve should parse shopifyInventoryItems.JSON so for each "tracked": false, we perform see here https://pastebin.com/BR6CFqAm
3. matchSkuToGetInventoryItemId();
Because only 60% of the source SKU correspond to an actual inventoryItemId, in the try catch we still have shopifyInventoryItems.JSON in memory so we compare source.JSON to match sku and write this two cases into source.json:
4. mutationInventoryBulkAdjustQuantityAtLocation();
finally we have source quantity and shopify InventoryItemId into source.json so pass the list of the "tracked": true on file to this,
mutation { inventoryBulkAdjustQuantityAtLocation(inventoryItemAdjustments: {inventoryItemId: "", availableDelta: 0}, locationId: "") }
Point 1: As far as GraphQL goes, this is the correct way to paginate until you run out of inventory items provided to goal is to get all inventory items.
Sorry, is there more of a question you're looking for an answer to? Everything you're mentioning seems ok but feel free to clarify any additional intent behind your post.
Cheers.
Hi @Alex
On my inventory data source I have only the total quantity of items. Do you know if I can use "inventoryBulkAdjustQuantityAtLocation" or I must use "inventoryItemUpdate"?
As far as I see inventoryBulkAdjustQuantityAtLocation require "availableDelta" an input object which is described as: the Count by which to adjust the available quantity.
Instead of "available" Field of method inventoryItemUpdate which is described as: Quantity of items available at the location. Which is the value I actually have on my end.
Thank you,
References:
inventoryBulkAdjustQuantityAtLocation --> https://shopify.dev/docs/admin-api/graphql/reference/mutation/inventorybulkadjustquantityatlocation
availableDelta --> https://shopify.dev/docs/admin-api/graphql/reference/mutation/input-object/inventoryadjustiteminput
inventoryItemUpdate --> https://shopify.dev/docs/admin-api/graphql/reference/mutation/inventoryitemupdate
available --> https://shopify.dev/docs/admin-api/graphql/reference/object/inventorylevel#fields-2020-07
Question about Shopify GraphQL mutation method inventoryBulkAdjustQuantityAtLocation seen at https://www.shopify.ca/partners/blog/multi-location_and_graphql
User | Count |
---|---|
15 | |
11 | |
10 | |
7 | |
5 |