Amazon SP-API Listings API putListingsItem 如何更新价格和数量? Node.js

问题描述 投票:0回答:2

我正在使用 amazon-sp-api(亚马逊销售合作伙伴 API 的 JavaScript 客户端),但这不仅限于此客户端。我想要做的就是使用 Amazon SP-API Listings API 的 putListingsItem 调用 来更新我列出的商品的价格和数量。

产品类型

根据 ListingsItemPutRequest 文档,此调用需要

productType
attributes

首先,要获取正确的

productType
值,您应该使用 产品类型定义 API 搜索产品定义类型。因此,我这样做,并调用 searchDefinitionsProductTypes,只是为了发现我的产品没有匹配的产品类型。

最终,我为

PRODUCT
字段给出了值
productType
。使用
PRODUCT
,我进行了
getDefinitionsProductType
调用并获得了一个包含
propertyNames
数组的对象,如下所示:


            "propertyNames": [
                "skip_offer",
                "fulfillment_availability",
                "map_policy",
                "purchasable_offer",
                "condition_type",
                "condition_note",
                "list_price",
                "product_tax_code",
                "merchant_release_date",
                "merchant_shipping_group",
                "max_order_quantity",
                "gift_options",
                "main_offer_image_locator",
                "other_offer_image_locator_1",
                "other_offer_image_locator_2",
                "other_offer_image_locator_3",
                "other_offer_image_locator_4",
                "other_offer_image_locator_5"
            ]
        },

看到这一点,我决定

list_price
fulfillment_availability
必须是 pricequantity,然后尝试在下面的代码中使用它们。

属性

还需要

attributes
值。然而,他们当前的文档没有显示如何为这些值添加什么的明确示例,而我必须将价格和数量放在某处。

我找到了有关 patchListingsItem 的链接,并尝试在下面实现该链接,但出现错误。

代码:

// trying to update quantity... failed.

        a.response =  await a.sellingPartner.callAPI({
            operation:'putListingsItem',
            path:{
              sellerId: process.env.SELLER_ID,
              sku: `XXXXXXXXXXXX`
            },
            query: {
              marketplaceIds: [ `ATVPDKIKX0DER` ]
            },
            body: {
              "productType": `PRODUCT`
              "requirements": "LISTING_OFFER_ONLY",
              "attributes": {
                    "fulfillment_availability": {
                        "fulfillment_channel_code": "AMAZON_NA",
                                "quantity": 4,
                                "marketplace_id": "ATVPDKIKX0DER"
                            }
                        }
          });

        console.log( `a.response: `, a.response )

错误:

{
    "sku": "XXXXXXXXXXXX",
    "status": "INVALID",
    "submissionId": "34e1XXXXXXXXXXXXXXXXXXXX",
    "issues": [
        {
            "code": "4000001",
            "message": "The provided value for 'fulfillment_availability' is invalid.",
            "severity": "ERROR",
            "attributeName": "fulfillment_availability"
        }
    ]
}

我也尝试过使用list_price:

// list_price attempt... failed.


        a.response =  await a.sellingPartner.callAPI({
            operation:'putListingsItem',
            path:{
              sellerId: process.env.SELLER_ID,
              sku: `XXXXXXXXXXXX`
            },
            query: {
              marketplaceIds: [ `ATVPDKIKX0DER` ]
            },
            body: {
              "productType": `PRODUCT`
              "requirements": "LISTING_OFFER_ONLY",
              "attributes": {
                    "list_price": {
                        "Amount": 90,
                        "CurrencyCode": "USD"
                    }
          });

        console.log( `a.response: `, a.response )

错误(这次似乎我变暖了……也许?):

{
    "sku": "XXXXXXXXXXXX",
    "status": "INVALID",
    "submissionId": "34e1XXXXXXXXXXXXXXXXXXXX",
    "issues": [
        {
            "code": "4000001",
            "message": "The provided value for 'list_price' is invalid.",
            "severity": "ERROR",
            "attributeName": "list_price"
        }
    ]
}

如何正确指定 list_price 或数量以使此调用成功?

只是尝试更新单个商品的价格和数量。

amazon-web-services aws-sdk amazon-mws amazonsellercentral amazon-selling-partner-api
2个回答
2
投票

这方面的文档很糟糕。不过,我已经通过相当多的尝试和错误成功地得到了其中的一些。

可以使用此 JSON 块设置履行和可用性

"fulfillment_availability": [{
"fulfillment_channel_code": "DEFAULT", 
"quantity": "9999", 
"lead_time_to_ship_max_days": "5"
}]
奇怪的是,标价是在这个区块中设定的。不过,我仍在尝试找出如何设置含税标价。

"purchasable_offer": [{ "currency": "GBP", "our_price": [{"schedule": [{"value_with_tax": 285.93}]}], "marketplace_id": "A1F83G8C2ARO7P" }]
希望这对您有帮助:)


0
投票
你试过打补丁吗?

我可以用这个 json 更新产品数量:

{ "productType":"BLANKET", "patches":[ { "op":"replace", "path":"/attributes/fulfillment_availability", "value": [ { "fulfillment_channel_code": "DEFAULT", "quantity": 33 } ] } ] }
在端点上打补丁:

{{host}}/listings/2021-08-01/items/:sellerID/:sku?marketplaceIds={{marketplaceid}}


    

© www.soinside.com 2019 - 2024. All rights reserved.