[英]Amazon SP-API Listings API putListingsItem How To Update price and quantity? Node.js
I am using amazon-sp-api (JavaScript client for the Amazon Selling Partner API) but this is not limited to this client.我正在使用amazon-sp-api (Amazon Selling Partner API 的 JavaScript 客户端),但这不仅限于此客户端。 All I want to do is use the Amazon SP-API Listings API's putListingsItem call to update the price and quantity of an item I have listed.
我要做的就是使用 Amazon SP-API Listings API 的putListingsItem 调用来更新我列出的商品的价格和数量。
productType产品类别
According to the ListingsItemPutRequest docs, productType
and attributes
are required for this call.根据ListingsItemPutRequest文档,此调用需要
productType
和attributes
。
Firstly, to obtain the correct productType
value, you are supposed to search for a product definitions type using the Product Type Definitions API .首先,要获得正确的
productType
值,您应该使用Product Type Definitions API搜索产品定义类型。 So, I do that, and call searchDefinitionsProductTypes , just to discover my product has no matching product type.所以,我这样做,并调用searchDefinitionsProductTypes ,只是为了发现我的产品没有匹配的产品类型。
Ultimately, I gave the value PRODUCT
for productType
field.最终,我为
productType
字段提供了值PRODUCT
。 Using PRODUCT
, I made the getDefinitionsProductType
call and got an object containing an array of propertyNames
, shown below:使用
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"
]
},
On seeing this, I decide list_price
and fulfillment_availability
must be the price and quantity and then try using these in my code below.看到这一点,我决定
list_price
和fulfillment_availability
必须是价格和数量,然后尝试在下面的代码中使用它们。
attributes属性
The attributes
value is also required. attributes
值也是必需的。 However, their current docs show no clear example of what to put for these values, which are where I must put price and quantity somewhere.但是,他们当前的文档没有显示为这些值添加什么的明确示例,这是我必须将价格和数量放在某处的地方。
I found this link about patchListingsItem and tried to implement that below but got an error.我找到了这个关于patchListingsItem的链接,并尝试在下面实现它,但出现错误。
code:代码:
// 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 )
error:错误:
{
"sku": "XXXXXXXXXXXX",
"status": "INVALID",
"submissionId": "34e1XXXXXXXXXXXXXXXXXXXX",
"issues": [
{
"code": "4000001",
"message": "The provided value for 'fulfillment_availability' is invalid.",
"severity": "ERROR",
"attributeName": "fulfillment_availability"
}
]
}
I also tried using list_price :我也尝试使用 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 )
Error (this time seems I got warmer... maybe?):错误(这次我好像变热了……也许吧?):
{
"sku": "XXXXXXXXXXXX",
"status": "INVALID",
"submissionId": "34e1XXXXXXXXXXXXXXXXXXXX",
"issues": [
{
"code": "4000001",
"message": "The provided value for 'list_price' is invalid.",
"severity": "ERROR",
"attributeName": "list_price"
}
]
}
How do you correctly specify the list_price or the quantity so this call will be successful?您如何正确指定 list_price 或数量,以便此调用成功?
Just tryin to update a single item's price and quantity.只是尝试更新单个项目的价格和数量。
The documentation for this side of things is terrible.这方面的文档很糟糕。 I've managed to get some of it through a fair bit of trial and error though.
不过,我已经设法通过相当多的试验和错误得到了一些。
Fulfillment and Availability can be set with this block of JSON可以使用此 JSON 块设置履行和可用性
"fulfillment_availability": [{
"fulfillment_channel_code": "DEFAULT",
"quantity": "9999",
"lead_time_to_ship_max_days": "5"
}]
and List price gets set, oddly, with this block.奇怪的是,这个块设置了标价。 I'm still trying to find out how to set the List Price with Tax however.
但是,我仍在尝试找出如何设置含税的标价。
"purchasable_offer": [{
"currency": "GBP",
"our_price": [{"schedule": [{"value_with_tax": 285.93}]}],
"marketplace_id": "A1F83G8C2ARO7P"
}]
Hope this helps you out :)希望这可以帮助你 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.