Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: How to update inventory data in batches through the API.

Solved

How to update inventory data in batches through the API.

Thomas_Li
New Member
4 0 0

I hope to be able to modify inventory data in batches by sku, only modifying the inventory without changing other data. Which part of the API documentation can achieve this function? Thank you

Accepted Solution (1)

Kyle_liu
Shopify Partner
286 38 51

This is an accepted solution.

Hi @Thomas_Li 

You cannot directly modify it through SKU. You need to first obtain the InventoryItemId based on SKU, and then modify it based on InventoryItemId

 

1、AdjustQuantities

{
    "input": {
        "name":"available",
        "reason":"correction",
        "changes": [
            {
                "inventoryItemId": "gid://shopify/InventoryItem/51676333768979",
                "delta": 10,
                "locationId": "gid://shopify/Location/85112553747"
            }
        ]
    }
}

 

2、inventorySetQuantities

{
    "input": {
        "name":"available",
        "reason":"correction",
        "ignoreCompareQuantity":true,
        "quantities": [
            {
                "inventoryItemId": "gid://shopify/InventoryItem/51676333768979",
                "quantity": 10,
                "locationId": "gid://shopify/Location/85112553747"
            }
        ]
    }
}

 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee

View solution in original post

Replies 4 (4)

Kyle_liu
Shopify Partner
286 38 51

This is an accepted solution.

Hi @Thomas_Li 

You cannot directly modify it through SKU. You need to first obtain the InventoryItemId based on SKU, and then modify it based on InventoryItemId

 

1、AdjustQuantities

{
    "input": {
        "name":"available",
        "reason":"correction",
        "changes": [
            {
                "inventoryItemId": "gid://shopify/InventoryItem/51676333768979",
                "delta": 10,
                "locationId": "gid://shopify/Location/85112553747"
            }
        ]
    }
}

 

2、inventorySetQuantities

{
    "input": {
        "name":"available",
        "reason":"correction",
        "ignoreCompareQuantity":true,
        "quantities": [
            {
                "inventoryItemId": "gid://shopify/InventoryItem/51676333768979",
                "quantity": 10,
                "locationId": "gid://shopify/Location/85112553747"
            }
        ]
    }
}

 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee
Thomas_Li
New Member
4 0 0

Thank you very much for your reply. These two APIs (AdjustQuantities/inventorySetQuantities) can be batch operated, right? Is there any difference in updating inventory? Thank you!

Kyle_liu
Shopify Partner
286 38 51

adjustQuantities: 20(old)+10(adjust)=30(new),

setQuantities: 20(old) => 10(set)  => 10(new)

 

Unfortunately, they do not support batch operations.

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee
Thomas_Li
New Member
4 0 0

Thank you for your reply. Do these two APIs (AdjustQuantities/inventorySetQuantities) not support batch operations? Is there an API that can batch update inventory operations?