Update shopify store inventory using shopify API and python

can you please check this code if it correct or not :

import shopify

Connect to the Shopify store

shop_url = ‘your-shop-name.myshopify.com
api_key = ‘your-api-key’
password = ‘your-api-password’
[email removed] % (api_key, password, shop_url))

Find the product you want to update

product = shopify.Product.find(123456789) # Replace 123456789 with the ID of the product

Update the inventory quantity

variant = product.variants[0] # Assuming there is only one variant
variant.inventory_quantity = 100 # Replace 100 with the new inventory quantity
variant.save()

1 Like