I'm trying to update products using the Shopify API. Here's a sample XML request to update the title, weight and inventory of a product:
<?xml version="1.0" encoding="UTF-8"?>
<product>
<id type="integer">100159400</id>
<title>150 Watt Mini Stereo Power Amplifier</title>
<variants type="array">
<variant>
<id type="integer">233139732</id>
<grams type="integer">700</grams>
<inventory-quantity type="integer">222</inventory-quantity>
</variant>
</variants>
</product>
I get a 200-OK after PUT /admin/products/100159400.xml. The title and weight (grams) get updated just fine, but not the inventory quantity. This is consistent for all other calls: I can update every field but the inventory quantity. Ideas?
That product does not have inventory tracking turned on. In your admin, you should see that the inventory level shows as infinity.
To change this and start tracking inventory, you need to set the inventory_management
field on the variant to shopify
. The following XML should do the trick:
<?xml version="1.0" encoding="UTF-8"?>
<product>
<id type="integer">100159400</id>
<title>150 Watt Mini Stereo Power Amplifier</title>
<variants type="array">
<variant>
<id type="integer">233139732</id>
<grams type="integer">700</grams>
<inventory-management>shopify</inventory-management>
<inventory-quantity type="integer">222</inventory-quantity>
</variant>
</variants>
</product>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With