创建一个包含多种变体和选项的新shopify产品

时间:2014-04-13 16:50:21

标签: shopify

我正在尝试通过Shopify API创建具有多种变体和选项的产品。 我应该如何为每个变体指定选项?我可以通过一次通话创建多个变种吗?谢谢!

这是我的JSON:

 {
 "handle":"carry-bag-grey",
  "body_html":"",
  "title":"Carry Bag(GREY)",   
  "product_type":"Women",
  "vendor":"MONOFOLD",
  "variants":[ 
  {
   "price":"23", 
   "fulfillment_service":"manual",
   "grams":"0",
   "inventory_management":"shopify",
   "inventory_policy":"deny",
   "sku":"MO1404180102",
   "taxable":"FALSE",
  "requires_shipping":"TRUE",
  "inventory_quantity":"2", 
  "Size":"6"
   },
  {
  "price":"23",
  "fulfillment_service":"manual",
  "grams":"0",
  "inventory_management":"shopify",
  "inventory_policy":"deny",
  "sku":"MO1404180103",
  "taxable":"FALSE",
  "requires_shipping":"TRUE",
  "inventory_quantity":"2",
  "Size":"6"
   }
 ]
}

我回来了ActiveResource::ResourceInvalid (Failed.),有人知道为什么吗?

1 个答案:

答案 0 :(得分:3)

是的,您可以通过一次调用创建多个变体。

See the Shopify API docs here

  

创建包含多个产品变体的新产品

POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestlye 151",
    "body_html": "<strong>Good snowboard!</strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
      {
        "option1": "First",
        "price": "10.00",
        "sku": 123
      },
      {
        "option1": "Second",
        "price": "20.00",
        "sku": "123"
      }
    ]
  }
}