MiGz
MiGz

Reputation: 592

Updating inventory quantities using the Shopify API

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?

Upvotes: 6

Views: 6801

Answers (1)

David Underwood
David Underwood

Reputation: 4966

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>

Upvotes: 6

Related Questions