首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >putListingsItem如何更新价格和数量?Node.js

putListingsItem如何更新价格和数量?Node.js
EN

Stack Overflow用户
提问于 2022-04-01 18:03:03
回答 1查看 1.1K关注 0票数 0

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

productType

根据ListingsItemPutRequest文档,这个调用需要productTypeattributes

首先,要获得正确的productType值,需要使用产品类型定义API搜索产品定义类型。因此,我这样做,并调用searchDefinitionsProductTypes,只是为了发现我的产品没有匹配的产品类型。

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

代码语言:javascript
运行
复制
            "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_pricefulfillment_availability必须是价格quantity,然后在下面的代码中尝试使用这些价格。

属性

attributes值也是必需的。但是,他们当前的文档并没有给出这些值的明确示例,这是我必须将价格和数量放在某个地方的地方。

我找到了关于patchListingsItem的这个链接,并试图在下面实现这个链接,但得到了一个错误。

代码:

代码语言:javascript
运行
复制
// 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 )

错误:

代码语言:javascript
运行
复制
{
    "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:

代码语言:javascript
运行
复制
// 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 )

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

代码语言:javascript
运行
复制
{
    "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或数量,以使此调用成功?

只需尝试更新一个项目的价格和数量。

EN

回答 1

Stack Overflow用户

发布于 2022-06-27 13:41:26

这方面的文档很糟糕。不过,我已经设法通过了一些尝试和错误。

可以用这个JSON块来设置实现和可用性

代码语言:javascript
运行
复制
"fulfillment_availability": [{
"fulfillment_channel_code": "DEFAULT", 
"quantity": "9999", 
"lead_time_to_ship_max_days": "5"
}]

奇怪的是,这个街区的清单价格被设定下来了。不过,我仍在设法找出如何用税来确定价目表。

代码语言:javascript
运行
复制
"purchasable_offer": [{
"currency": "GBP",
"our_price": [{"schedule": [{"value_with_tax": 285.93}]}],
"marketplace_id": "A1F83G8C2ARO7P"
}]

希望这能帮你:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71711129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档