开放Api-产品-更新

Api描述:商家端,更新产品

URL: /manager/api/apps/openapi/product/save

格式:json

方式:post

数据请求部分

1.Request Header 参数:

参数名称 是否必须 类型 描述
open-access-token 必须 String 在开放api插件中,创建权限后即可获取该token

2.Request JSON Data(Body):

参数名称 是否必须 类型 描述
product 必须 array 产品主题数据
product > id 必填 string 产品id,创建产品不填写,更新产品必填
product > spu 选填 string 产品spu
product > title 必须 string 产品标题
product > sub_title 选填 string 产品副标题
product > body_html 必须 string 产品描述
product > meta_title 选填 string 【seo标题】 meta title
product > meta_keywords 选填 string 【seo关键字】 meta keywords
product > meta_description 选填 string 【seo描述】 meta description
product > handle 选填 string 【seo链接】 产品url path, 如果不填写,则使用title字符串生成
product > status 选填 string 产品状态,1代表上架,2代表下架 ,默认为上架
product > type 必填 string 产品规格类型,1为单规格,2为多规格(规格指的是颜色,尺码等)
product > virtual_sales_count 选填 int 产品虚拟销量
product > meta_is_edit 选填 int 1代表非独立编辑,2代表独立编辑
product > vendor 选填 string 产品厂家名称(品牌名称)
product > variant_need_image 选填 int 产品规格是否需要图片, 1代表需要,2代表不需要 默认为1需要
product > variant_need_note 选填 int 变体是否需要备注,1代表需要备注,2代表不需要备注
product > inventory_police 选填 int 是否跟踪库存,1为跟踪,2为不跟踪,默认为1跟踪库存
product > inventory_police_type 选填 int 1为库存为0,允许购买,2为库存为0不允许购买,3为库存为0,则产品直接下架。(默认为1允许购买)
images 必填 array 产品图片
images > id 选填 int 产品图片id,如果是创建图片则不需要填写,如果是更新产品,更新产品图片,则必须填写。(注意,更新产品的某个图片,需要在该id上面更新,而不是创建一个新的图片,除非用户删除图片)
images > src 必须 string 产品图片路径
images > alt 选填 string 图片 alt
images > position 必须 string 产品图片位置,按照顺序,从1开始,依次递增(必须从1开始,标识为1的将作为主图)
collection_ids 选填 array[int] 产品对应的 专辑ids 数组,一个产品可以对应多个专辑,是多对多关系,因此这里是数组可以,可以传递多个专辑id
options 选填 array 单规格为空,多规格必填不为空
options > id 选填 int 更新规格必填,创建规格不需要填写
options > name 必须 string 规格名称
options > position 必须 string 规格排序
options > items 必须 array 规格子项数组
variants 必须 array 产品变体(规格) ,当为单规格产品,将属性填写到该部分下面即可(数组只有一个子项)
variants > id 选填 int 产品变体id,创建不需要填写,更新必填
variants > cost_price 选填 float 产品变体-成本价格
variants > price 必填 float 产品变体-售卖价格
variants > compare_at_price 选填 float 产品变体-划线价格
variants > sku 必须/选填 string 产品变sku,根据配置项,来决定必填唯一,选填唯一,选填非唯一
variants > barcode 选填 string 产品变体条形码
variants > image 选填 string 产品变体图片路径(这里填写路径即可,在保存的时候,会到产品图片表里面查找,找到得到image_id,然后赋值。),注意,这里的image,必须在 images参数中存在,否则将无法保存
variants > qty 必须 string 产品变体库存,默认0
variants > option1 选填 string 产品变体规格1
variants > option2 选填 string 产品变体规格2
variants > option3 选填 string 产品变体规格3
variants > weight 必须 string 产品变体重量
variants > weight_unit 必须 string 产品变体重量单位
variants > note 选填 string 产品变体备注

post示例数据:(创建产品的例子)

{
    "product": {
        "id": 654,
        "spu": "xxxxx",
        "title": "Cartoon Bear Printing Women's Cardigan Pajamas Short Sleeve Shorts Household Clothing Suit",
        "sub_title": "",
        "body_html": "The fashionable cardigan pajamas has a cute cartoon bear print which adds more charm to your look.",
        "status": 1,
        "virtual_sales_count" : 0,
        "meta_is_edit": 1,
        "type": 2,
        "vendor": "",
        "variant_need_image": 1,
        "inventory_police": 1,
        "inventory_police_type": 1,
        "meta_title": "Cartoon Bear Printing Women's Cardigan Pajamas Short Sleeve Shorts Household Clothing Suit",
        "meta_keywords": "",
        "meta_description": "The fashionable cardigan pajamas has a cute cartoon bear print which adds more charm to your look.",
        "handle": "cartoon-bear-printing-womens-cardigan-pajamas-short-sleeve-shorts-household-clothing-suit",
        "variant_need_note": "1"
    },
    "images": [
        {
            "id": 7388,
            "position": 1,
            "src": "/product/15/image/2023/01/30/5b17ccf2483c46a900f569aac7924c61.jpg",
            "alt": ""
        },
        {
            "id": 7389,
            "position": 2,
            "src": "/product/15/image/2023/01/30/b169d0172b6e8f474aa47190160434f0.jpg",
            "alt": ""
        },
        {
            "id": 7390,
            "position": 3,
            "src": "/product/15/image/2023/01/30/7ffd9f95c0c286688a4227ada013ad46.jpg",
            "alt": ""
        },
        {
            "id": 7391,
            "position": 4,
            "src": "/product/15/image/2023/01/30/c9e676731970bce0df818ad76c8ec6ea.jpg",
            "alt": ""
        },
        {
            "id": 7392,
            "position": 5,
            "src": "/product/15/image/2023/01/30/480d64f2fca90319e4d899d6f63a8735.jpeg",
            "alt": ""
        },
        {
            "id": 7393,
            "position": 6,
            "src": "/product/15/image/2023/01/30/3f0b6db5065e0ac910940f3b0bd8e445.jpg",
            "alt": ""
        }
    ],
    "collection_ids": [44],
    "options": [
        {
            "id": 827,
            "name": "Color",
            "position": 1,
            "items": [
                "Green"
            ]
        },
        {
            "id": 828,
            "name": "Size",
            "position": 2,
            "items": [
                "M",
                "L",
                "XL",
                "2XL",
                "3XL"
            ]
        }
    ],
    "variants": [
        {
            "id": 4380,
            "price": "13.28",
            "compare_at_price": "0.00",
            "cost_price": "0.00",
            "sku": "697712001652L28037",
            "barcode": "",
            "qty": 79,
            "option1": "Green",
            "option2": "M",
            "option3": "",
            "weight": "0.00",
            "weight_unit": "kg",
            "note": "",
            "image": "/product/15/image/2023/01/30/b169d0172b6e8f474aa47190160434f0.jpg"
        },
        {
            "id": 4381,
            "price": "13.28",
            "compare_at_price": "0.00",
            "cost_price": "0.00",
            "sku": "697712001652M28037",
            "barcode": "",
            "qty": 66,
            "option1": "Green",
            "option2": "L",
            "option3": "",
            "weight": "0.00",
            "weight_unit": "kg",
            "note": "",
            "image": "/product/15/image/2023/01/30/b169d0172b6e8f474aa47190160434f0.jpg"
        },
        {
            "id": 4382,
            "price": "13.28",
            "compare_at_price": "0.00",
            "cost_price": "0.00",
            "sku": "697712001652XL28037",
            "barcode": "",
            "qty": 97,
            "option1": "Green",
            "option2": "XL",
            "option3": "",
            "weight": "0.00",
            "weight_unit": "kg",
            "note": "",
            "image": "/product/15/image/2023/01/30/b169d0172b6e8f474aa47190160434f0.jpg"
        },
        {
            "id": 4383,
            "price": "13.28",
            "compare_at_price": "0.00",
            "cost_price": "0.00",
            "sku": "697712001652XXL28037",
            "barcode": "",
            "qty": 123,
            "option1": "Green",
            "option2": "2XL",
            "option3": "",
            "weight": "0.00",
            "weight_unit": "kg",
            "note": "",
            "image": "/product/15/image/2023/01/30/b169d0172b6e8f474aa47190160434f0.jpg"
        },
        {
            "id": 4384,
            "price": "13.28",
            "compare_at_price": "0.00",
            "cost_price": "0.00",
            "sku": "697712001652XXXL28037",
            "barcode": "",
            "qty": 70,
            "option1": "Green",
            "option2": "3XL",
            "option3": "",
            "weight": "0.00",
            "weight_unit": "kg",
            "note": "",
            "image": "/product/15/image/2023/01/30/b169d0172b6e8f474aa47190160434f0.jpg"
        }
    ]
}


数据返回部分

1.Response JSON Data(Body):

格式:json

参数名称 是否必须 类型 描述
code 必须 Number 200 代表成功
message 必须 String 执行结果的文字描述信息
data 必须 Array api获取的数据保存到data中
data > product_id 必须 int 产品id

Response JSON Data(示例数据):

{
    "code": 200,
    "data": {
        "product_id": 4
    },
    "message": "success"
}
Copyright © fecify.com 2022 all right reserved,powered by Gitbook该文件修订时间: 2024-01-14 16:16:11

results matching ""

    No results matching ""