Sphere.IO:我们如何在产品创建过程中设置自定义属性?

时间:2015-09-15 10:59:01

标签: commercetools sphere.io


在我们创建了一个productType并且其类型为id之后,我们如何在产品创建API调用期间设置自定义属性。到现在为止我正在做的是第一,创建产品,然后更新自定义属性。但是,我无法使用必需的属性。

1 个答案:

答案 0 :(得分:1)

您可以在产品创建有效内容中提供所有自定义属性。示例 - 这里我为主变体提供属性品牌的值,对于先前创建的产品类型,它指定存在名为Brand的属性:

  {
  "productType": {
    "typeId": "product-type",
    "id": "6c06998a-c576-4a8d-8ace-dc306d70e1d1"
  },
  "name": {
    "en": "Some Product"
  },
  "slug": {
    "en": "product_slug_sdfsdfsdfdsdfsdfdssdf"
  },
  "masterVariant": {
    "prices": [{
      "value": {
        "centAmount": 2500,
        "currencyCode": "EUR"
      },
      "country": "US"
    }],
    "attributes": [{
      "name": "brand",
      "value": "Hugo Boss"
    }]
  },
  "variants": [{
    "prices": [{
      "value": {
        "centAmount": 2600,
        "currencyCode": "EUR"
      },
      "country": "US"
    }],
    "attributes": [{
      "name": "brand",
      "value": "Hugo Boss"
    }]
  }]
}