提问者:小点点

创建具有多个变体和选项的新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(失败),有人知道为什么吗?


共1个答案

匿名用户

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

请参见此处的Shopify API文档:

创建具有多个产品变体的新产品

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"
      }
    ]
  }
}