无法使用补丁/放置列表更新库存Amazon SP API with PHP

lokaqttq  于 2023-02-18  发布在  PHP
关注(0)|答案(1)|浏览(125)

我需要你的帮助,我尝试了所有提到的建议(https://github.com/amzn/selling-partner-api-docs/issues/2167),但仍然无法更新库存数量与亚马逊SP API。
我正在尝试更新没有饲料的库存数量。
下面的身体,我发送更新的数量与把请求。
我使用的软件包是:https://github.com/jlevers/selling-partner-api

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
                        )
                )
        )
)

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

........
            [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] => 
                                )
                        )
                )
........

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

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
                        )
                )
        )
)

获得以下响应。

Exception when calling: [400] {
  "errors": [
    {
      "code": "InvalidInput",
      "message": "Request has missing or invalid parameters and cannot be parsed.",
      "details": ""
    }
  ]
}

有没有什么方法可以在不使用feedsAPI的情况下将订单状态更新为已发货?
到目前为止我尝试的代码如下。

$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;
}
2izufjch

2izufjch1#

我发现解决方案的主要问题是在有许多不同的方法,这是由亚马逊饲料基地或上市放/补丁基地提供。
在我的问题中,我使用的是基于列表的方法。
终结点URL如下。

{{fe_url}}/listings/2021-08-01/items/{{seller_id}}/8001025974?marketplaceIds={{jp_market_id}}

正文应该如下所示。如果产品类型中有错误,即使您传递当前产品类型,也只需使用**“PRODUCT”**代替。

**注意:**但如果您使用的是Feed文档,则可能会将其更改为see here

我在下面的身体上取得了成功。

{
    "productType": "PRODUCT",
    "patches": [
        {
            "op": "replace",
            "operation_type": "PARTIAL_UPDATE",
            "path": "/attributes/fulfillment_availability",
            "value": [
                {
                    "fulfillment_channel_code": "DEFAULT",
                    "quantity": 0
                }
            ]
        }
    ]
}

相关问题