How can I update inventory quantity via API?

Solved
Coludus
Tourist
8 0 2

I would like to change inventory quantity of products, but I don't even know how to do that.

Here is a part of example to list a product I try to do.

product = shopify.Product()
product.title = "example"
product.save()

 

Accepted Solution (1)

Accepted Solutions
etrolmos
Shopify Partner
22 1 5

This is an accepted solution.

The SDK should be similar to Shopify Admin API, so check the API docs on inventory handling:

https://shopify.dev/api/admin/rest/reference/inventory 

https://shopify.dev/api/examples/product-inventory

Inventory is now tracked against InventoryItem and InventoryLevel in connection to a Location on each product variant.

I'm not familiar with the Python SDK, not sure if InventoryItem will be auto-populated on the Variant object, but I'm guessing after saving the product, you can do something like:

inv = shopify.InventoryLevel()
inv.set(inventory_item_id=variant.inventory_item_id, location_id=<location id>, available=<quantity>)

Should return a collection, then call set() method to set the inventory for a location.

View solution in original post

Replies 2 (2)
etrolmos
Shopify Partner
22 1 5

This is an accepted solution.

The SDK should be similar to Shopify Admin API, so check the API docs on inventory handling:

https://shopify.dev/api/admin/rest/reference/inventory 

https://shopify.dev/api/examples/product-inventory

Inventory is now tracked against InventoryItem and InventoryLevel in connection to a Location on each product variant.

I'm not familiar with the Python SDK, not sure if InventoryItem will be auto-populated on the Variant object, but I'm guessing after saving the product, you can do something like:

inv = shopify.InventoryLevel()
inv.set(inventory_item_id=variant.inventory_item_id, location_id=<location id>, available=<quantity>)

Should return a collection, then call set() method to set the inventory for a location.

Coludus
Tourist
8 0 2

Thank you for your help

I didn't even understand what location was.

I could manage inventory.

I appreciate it again!