Skip to content

关于 变体

访问范围

需要多个访问范围—请参阅每个端点以了解访问范围要求。

需要访问受保护的客户数据。

产品变体 是指同一产品的不同规格版本,通常包括颜色、尺寸或其他属性的变化。Genstore 提供了一系列 RESTful 接口,用于管理这些产品变体的详细信息,包括创建新变体、检索变体列表、获取特定变体详情、更新变体信息以及删除变体的操作。

核心功能

  • 基础操作:创建变体、更新变体、删除变体。
  • 信息查询:获取变体列表、获取产品变体详情、获取产品变体数量。

应用场景

  • 产品规格管理:商家可以通过 API 为同一产品添加不同规格的变体,如颜色和尺寸,方便管理多规格商品,满足不同客户的购买需求。
  • 库存管理:通过 API,仓库管理系统可以根据变体的信息更新库存状态,确保每个变体的库存数据准确无误,便于库存控制。
  • 快速产品更新:商家可以快速更新变体的价格、库存等信息,以适应市场变化,确保产品信息的及时性和竞争力。

产品变体 对象

产品变体业务对象。

属性

productVariantobject
产品变体信息。
- 收起属性
variantIdnumber
变体的唯一标识符。
productIdnumber
产品的唯一标识符。
skustring
变体的唯一区分大小写标识符。
barcodestring
变体条形码。
compareOfPricenumber
市场价。
pricenumber
销售价。
costPricenumber
成本价。
weightnumber
重量。
weightUnitstring
重量单位。
isDisabledboolean
是否禁用。
inventoryManagementboolean
库存管理。
optionsarray
自定义属性信息。
+ 展开属性
inventoryQuantitiesarray
库存信息。
+ 展开属性
bash
{
  "productVariant": {
    "inventoryManagement": "true",
    "productId": "102744460756584",
    "costPrice": "3",
    "weight": "1",
    "compareOfPrice": "22",
    "inventoryQuantities": [
      {
        "locationId": "50002",
        "available": "666"
      }
    ],
    "price": "10",
    "options": [
      {
        "name": "size",
        "id": "10034623756584",
        "position": "1",
        "value": {
          "name": "L",
          "id": "10167791756584",
          "position": "1"
        }
      }
    ],
    "variantId": "107362030756584",
    "isDisabled": "false",
    "sku": "P001",
    "barcode": "AXOYX49XOPEX6",
    "weightUnit": "kg"
  }
}

POST 创建变体

创建变体。

访问范围

需要以下任意访问权限: write_products

接口

POST /api/202412/product/{productId}/variants 

请求参数

productVariantobject
产品变体信息。
- 收起属性
productIdnumber
产品的唯一标识符。
skustring
变体的唯一区分大小写标识符。
barcodestring
变体条形码。
compareOfPricenumber
市场价。
pricenumber
销售价。
costPricenumber
成本价。
weightnumber
重量。
weightUnitstring
重量单位。
isDisabledboolean
是否禁用。
inventoryManagementboolean
库存管理。
optionsarray
自定义属性信息。
+ 展开属性
inventoryQuantitiesarray
库存信息。
+ 展开属性

响应数据

productVariantobject
产品变体信息。
- 收起属性
variantIdnumber
变体的唯一标识符。
productIdnumber
产品的唯一标识符。
skustring
变体的唯一区分大小写标识符。
barcodestring
变体条形码。
compareOfPricenumber
市场价。
pricenumber
销售价。
costPricenumber
成本价。
weightnumber
重量。
weightUnitstring
重量单位。
isDisabledboolean
是否禁用。
inventoryManagementboolean
库存管理。
optionsarray
自定义属性信息。
+ 展开属性
inventoryQuantitiesarray
库存信息。
+ 展开属性
bash
curl -X POST \ 
https://{shop}.genmystore.com/api/202412/product/{productId}/variants" \ 
-H "X-Genstore-Access-Token: {access_token}" \ 
-H "Content-Type: application/json" \ 
-d '{
	"productVariant":{
		"inventoryManagement":"true",
		"productId":"102744460756584",
		"price":"10",
		"costPrice":"3",
		"options":[
			{
				"name":"size",
				"id":"10034623756584",
				"position":"1",
				"value":{
					"name":"L",
					"id":"10034623756585",
					"position":"1"
				}
			}
		],
		"weight":"1",
		"isDisabled":"true",
		"sku":"P001",
		"compareOfPrice":"22",
		"barcode":"AXOYX49XOPEX6",
		"inventoryQuantities":[
			{
				"locationId":"50002",
				"available":"666"
			}
		],
		"weightUnit":"kg"
	}
}'
json
HTTP/1.1 200 OK
{
  "productVariant": {
    "inventoryManagement": "true",
    "productId": "102744460756584",
    "costPrice": "3",
    "weight": "1",
    "compareOfPrice": "22",
    "inventoryQuantities": [
      {
        "locationId": "50002",
        "available": "666"
      }
    ],
    "price": "10",
    "options": [
      {
        "name": "size",
        "id": "10167791756584",
        "position": "1",
        "value": {
          "name": "L",
          "id": "10167791756585",
          "position": "1"
        }
      }
    ],
    "variantId": "107362030756584",
    "isDisabled": "true",
    "sku": "P001",
    "barcode": "AXOYX49XOPEX6",
    "weightUnit": "kg"
  }
}

PUT 更新变体

更新变体。

访问范围

需要以下任意访问权限: write_products

接口

PUT /api/202412/variants 

请求参数

productVariantobject
产品变体信息。
- 收起属性
variantIdnumber
变体的唯一标识符。
productIdnumber
产品的唯一标识符。
skustring
变体的唯一区分大小写标识符。
barcodestring
变体条形码。
compareOfPricenumber
市场价。
pricenumber
销售价。
costPricenumber
成本价。
weightnumber
重量。
weightUnitstring
重量单位。
isDisabledboolean
是否禁用。
inventoryManagementboolean
库存管理。
inventoryQuantitiesarray
库存信息。
+ 展开属性

响应数据

productVariantobject
产品变体信息。
- 收起属性
variantIdnumber
变体的唯一标识符。
productIdnumber
产品的唯一标识符。
skustring
变体的唯一区分大小写标识符。
barcodestring
变体条形码。
compareOfPricenumber
市场价。
pricenumber
销售价。
costPricenumber
成本价。
weightnumber
重量。
weightUnitstring
重量单位。
isDisabledboolean
是否禁用。
inventoryManagementboolean
库存管理。
optionsarray
自定义属性信息。
+ 展开属性
inventoryQuantitiesarray
库存信息。
+ 展开属性
bash
curl -X PUT \ 
https://{shop}.genmystore.com/api/202412/variants" \ 
-H "X-Genstore-Access-Token: {access_token}" \ 
-H "Content-Type: application/json" \ 
-d '{
	"productVariant":{
		"inventoryManagement":"true",
		"productId":"102744460756584",
		"price":"1",
		"costPrice":"1",
		"weight":"1",
		"variantId":"107362030756584",
		"isDisabled":"false",
		"sku":"P001",
		"compareOfPrice":"1",
		"barcode":"AXOYX49XOPEX6",
		"inventoryQuantities":[
			{
				"locationId":"50002",
				"available":"60"
			}
		],
		"weightUnit":"kg"
	}
}'
json
HTTP/1.1 200 OK
{
  "productVariant": {
    "inventoryManagement": "true",
    "productId": "102744460756584",
    "costPrice": "1",
    "weight": "1",
    "compareOfPrice": "1",
    "inventoryQuantities": [
      {
        "locationId": "50002",
        "available": "60"
      }
    ],
    "price": "1",
    "options": [
      {
        "name": "size",
        "id": "10034623756584",
        "position": "1",
        "value": {
          "name": "L",
          "id": "10034623756585",
          "position": "1"
        }
      }
    ],
    "variantId": "107362030756584",
    "isDisabled": "false",
    "sku": "P001",
    "barcode": "AXOYX49XOPEX6",
    "weightUnit": "kg"
  }
}

DELETE 删除变体

删除变体。

访问范围

需要以下任意访问权限: write_products

接口

DELETE /api/202412/variants/{variantId} 

请求参数

variantIdnumber
变体的唯一标识符。

响应数据

{}
bash
curl -X DELETE \ 
https://{shop}.genmystore.com/api/202412/variants/{variantId}" \ 
-H "X-Genstore-Access-Token: {access_token}" \
json
HTTP/1.1 200 OK
{}

GET 获取变体详情

获取产品变体详情。

访问范围

需要以下任意访问权限: write_products read_products

接口

GET /api/202412/variants/{variantId} 

请求参数

variantIdnumber
变体的唯一标识符。

响应数据

productVariantobject
产品变体信息。
- 收起属性
variantIdnumber
变体的唯一标识符。
productIdnumber
产品的唯一标识符。
skustring
变体的唯一区分大小写标识符。
barcodestring
变体条形码。
compareOfPricenumber
市场价。
pricenumber
销售价。
costPricenumber
成本价。
weightnumber
重量。
weightUnitstring
重量单位。
isDisabledboolean
是否禁用。
inventoryManagementboolean
库存管理。
optionsarray
自定义属性信息。
+ 展开属性
inventoryQuantitiesarray
库存信息。
+ 展开属性
bash
curl -X GET \ 
https://{shop}.genmystore.com/api/202412/variants/{variantId}" \ 
-H "X-Genstore-Access-Token: {access_token}" \
json
HTTP/1.1 200 OK
{
  "productVariant": {
    "inventoryManagement": "true",
    "productId": "102744460756584",
    "costPrice": "3",
    "weight": "1",
    "compareOfPrice": "22",
    "inventoryQuantities": [
      {
        "locationId": "50002",
        "available": "666"
      }
    ],
    "price": "10",
    "options": [
      {
        "name": "size",
        "id": "10034623756584",
        "position": "1",
        "value": {
          "name": "L",
          "id": "10167791756584",
          "position": "1"
        }
      }
    ],
    "variantId": "107362030756584",
    "isDisabled": "false",
    "sku": "P001",
    "barcode": "AXOYX49XOPEX6",
    "weightUnit": "kg"
  }
}