【发布时间】:2022-06-27 21:41:26
【问题描述】:
我正在使用amazon-sp-api(亚马逊销售合作伙伴 API 的 JavaScript 客户端),但这不限于此客户端。我要做的就是使用 Amazon SP-API Listings API 的putListingsItem call 来更新我列出的商品的价格和数量。
产品类型
根据ListingsItemPutRequest 文档,此调用需要productType 和attributes。
首先,要获得正确的productType 值,您应该使用Product Type Definitions API 搜索产品定义类型。所以,我这样做了,并打电话给searchDefinitionsProductTypes,只是为了发现我的产品没有匹配的产品类型。
最终,我为productType 字段提供了值PRODUCT。使用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 必须是 price 和 quantity,然后尝试在下面的代码中使用它们。
属性
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 amz-sp-api