2012-08-29 24 views
5

Shopify APIを使用して製品を更新しようとしています。ここでは、製品のタイトル、重量と在庫を更新するためのサンプルXMLリクエストです:Shopify APIを使用して在庫数を更新する

<?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> 

私はPUTの/admin/products/100159400.xml後200-OKをもらいます。タイトルと重量(グラム)はうまく更新されますが、在庫量は更新されません。これは、他のすべての呼び出しで一貫しています。在庫量以外のすべてのフィールドを更新できます。アイデア?

答えて

6

この商品の在庫追跡は有効になっていません。管理者は、在庫レベルが無限大として表示されるはずです。

これを変更して在庫追跡を開始するには、バリアントのinventory_managementフィールドをshopifyに設定する必要があります。次のXMLはこのトリックを行う必要があります。

<?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> 
+0

ありがとうございました。それはうまくいった。製品が在庫追跡を有効にしているときに、Shopifyで何が起きるかについて、より詳細な情報がどこにあるのか教えていただけますか? – user1595471

+0

PUTの使い方を教えてください。私はちょうどcURLとPOST cURLリクエストを取得することができます。しかし、私はPUTの代わりにPUTを使用すると動作しません。 –

関連する問題