Sphere.IO : 我们如何在产品创建过程中设置自定义属性?
Sphere.IO : How can we set a custom attribute during product creation?
在我们创建了一个 productType 并拥有其类型 ID 之后,我们如何在调用 product create API 期间设置自定义属性。到目前为止我正在做的是 1st,创建产品,然后更新自定义属性。但是,我无法使用必需的属性这样做。
您可以在产品创建负载中提供所有自定义属性。示例 - 在这里,我为先前创建的产品类型提供了主变体上的品牌属性值,该产品类型指定有一个名为品牌的属性:
{
"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"
}]
}]
}
在我们创建了一个 productType 并拥有其类型 ID 之后,我们如何在调用 product create API 期间设置自定义属性。到目前为止我正在做的是 1st,创建产品,然后更新自定义属性。但是,我无法使用必需的属性这样做。
您可以在产品创建负载中提供所有自定义属性。示例 - 在这里,我为先前创建的产品类型提供了主变体上的品牌属性值,该产品类型指定有一个名为品牌的属性:
{
"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"
}]
}]
}