首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法用补丁/put更新库存,用PHP列出Amazon

无法用补丁/put更新库存,用PHP列出Amazon
EN

Stack Overflow用户
提问于 2022-07-28 03:44:35
回答 1查看 306关注 0票数 1

我需要你的帮助,我尝试了所有提到的建议(https://github.com/amzn/selling-partner-api-docs/issues/2167),但仍然无法用Amazon更新库存数量。

我正在尝试更新没有提要的数量库存。

下面的正文,我是发送更新数量和投入的要求。

我使用的包是:https://github.com/jlevers/selling-partner-api

代码语言:javascript
运行
复制
SellingPartnerApi\Model\ListingsV20210801\ListingsItemPutRequest Object
(
    [container:protected] => Array
        (
            [product_type] => FALSE_EYELASH
            [requirements] => 
            [attributes] => Array
                (
                    [fulfillment_availability] => Array
                        (
                            [fulfillment_channel_code] => AMAZON_JP
                            [quantity] => 5
                        )
                )
        )
)

当我使用沙箱时,得到一个响应,接受了,但是没有错误。

代码语言:javascript
运行
复制
........
            [sku] => 2629-48KGT-2347 // TEST
            [status] => INVALID
            [submission_id] => 602b84b73b964e24b174a80d3a7870a3
            [issues] => Array
                (
                    [0] => SellingPartnerApi\Model\ListingsV20210801\Issue Object
                        (
                            [container:protected] => Array
                                (
                                    [code] => 4000003
                                    [message] => ������������Amazon������������������������������������������������������������������������������
                                    [severity] => ERROR
                                    [attribute_names] => 
                                )
                        )
                )
........

=======================

为了修补请求,我正在尝试下面的身体。

代码语言:javascript
运行
复制
SellingPartnerApi\Model\ListingsV20210801\ListingsItemPatchRequest Object
(
    [container:protected] => Array
        (
            [product_type] => FALSE_EYELASH
            [patches] => Array
                (
                    [op] => replace
                    [operation_type] => UPDATE    // Already try with or without this parameter
                    [path] => /attributes/fulfillment_availability
                    [value] => Array
                        (
                            [fulfillment_channel_code] => AMAZON_JP
                            [quantity] => 5
                        )
                )
        )
)

得到下面的回应。

代码语言:javascript
运行
复制
Exception when calling: [400] {
  "errors": [
    {
      "code": "InvalidInput",
      "message": "Request has missing or invalid parameters and cannot be parsed.",
      "details": ""
    }
  ]
}

是否有任何方法来更新订单状态,使之在没有提要API的情况下交付?

到目前为止,我尝试的代码如下。

代码语言:javascript
运行
复制
$patchBody = [
    'product_type' => 'BEAUTY',
    'marketplaceIds' => ['A1VC38T7YXB528'], // Already try with or without
    'patches' => [
        [
            "op" => "replace",
            "operation_type" => "PARTIAL_UPDATE",
            "path" => "/attributes/fulfillment_availability",
            "value" => [
                [
                    "fulfillment_channel_code" => 'DEFAULT',
                    "quantity" => 2
                ]
            ]
        ]
    ]
];

$putBody = [
    'product_type' => 'BEAUTY',
    'attributes' => [
        "fulfillment_availability" => [
            "fulfillment_channel_code" => "DEFAULT",
            "quantity" => 2
        ]
    ]
];

$seller_id = 'MY-SELLER-ID';
$sku = '8001025974';
$marketplace_ids = array('A1VC38T7YXB528');

// Update inventory
$apiInstance = new SellingPartnerApi\Api\ListingsV20210801Api($config);

$body = new \SellingPartnerApi\Model\ListingsV20210801\ListingsItemPatchRequest($patchBody);
// $issue_locale = 'en_US';

try {
    $result = $apiInstance->patchListingsItem($seller_id, $sku, $marketplace_ids, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling: ', $e->getMessage(), PHP_EOL;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-03 06:01:35

我找到了解决方案,主要问题是在body中,有许多不同的方法是由amazon基础或列表put/修补程序库提供的。

在我的问题中,我使用的是基于列表的方法。

端点URL在下面。

代码语言:javascript
运行
复制
{{fe_url}}/listings/2021-08-01/items/{{seller_id}}/8001025974?marketplaceIds={{jp_market_id}}

身体应该像下面这样。如果产品类型有错误,即使您传递当前的产品类型,只需使用" product "

注释:,但是如果您使用提要文档,那么它可能会被更改为请看这里

我从下面的身体中获得了成功。

代码语言:javascript
运行
复制
{
    "productType": "PRODUCT",
    "patches": [
        {
            "op": "replace",
            "operation_type": "PARTIAL_UPDATE",
            "path": "/attributes/fulfillment_availability",
            "value": [
                {
                    "fulfillment_channel_code": "DEFAULT",
                    "quantity": 0
                }
            ]
        }
    ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73147023

复制
相关文章

相似问题

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