amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
612 stars 739 forks source link

Listings API patchListingsItem operation possible fulfillment_channel_code replace issue #2061

Closed NetrushAbhijit closed 2 years ago

NetrushAbhijit commented 2 years ago

Hello,

With reference to: API: Listings Operation: patchListingsItem

We noticed that - when we tried updating the fulfillment_channel_code on a listing using the 'patchListingsItem' operation, it created an additional fulfillment_channel_code on the listing instead of replacing an existing one.

Here's what we tried - On one of our SKUs, we tried flipping the fulfillment_channel_code from 'DEFAULT' (MFN) to 'AMAZON_NA' (FBA) by firing the below mentioned request.

{
    {
        "productType": "PRODUCT",
        "patches": [
            {
                "op": 1, //Replace
                "path": "/attributes/fulfillment_availability",
                "value": [
                    {
                        "fulfillment_channel_code": "AMAZON_NA",
                        "quantity": 0
                    }
                ]
            }
        ]
    },
    "sellerId ": "[SellerId]",
    "sku": "[SKU]",
    "marketplaceIds": [
        "ATVPDKIKX0DER"
    ],
    "issueLocale": "en_US"
}

We then fired the Listings API 'getListingsItem' to see how it looks like on the listing and found below json under the fulfillment_availability node of the response:

"attributes": {
        "fulfillment_availability": [
            {
                "fulfillment_channel_code": "DEFAULT",
                "quantity": 21,
                "marketplace_id": "ATVPDKIKX0DER"
            },
            {
                "fulfillment_channel_code": "AMAZON_NA",
                "quantity": 0,
                "marketplace_id": "ATVPDKIKX0DER"
            }
        ],

So, instead of replacing existing "fulfillment_channel_code": "DEFAULT", it created a new fulfillment_channel_code. So, just wondering if this is by design or we are missing something?

Thanks, Abhijit

NetRushJacob commented 2 years ago

@NetrushAbhijit you might indicate the outcome on SellerCentral that you see with both of these nodes: Are there two listings (FBA + MFN) or a single FBA or MFN?

hinavinayak commented 2 years ago

The Product Types Definitions API defines which fields of an attribute are its selectors (i.e. what uniquely defines the instance of an attribute in the list). In the case of fulfillment_availability, the selector is fulfillment_channel_code. When it comes to updating the listing, such as with the PATCH operation, only the attribute instances with the same selector value will be updated.

So, sending this:

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

Would add or replace the fulfillment_availability instance for the "DEFAULT" fulfillment_channel_code selector.

If you want to remove an instance, you can use the PATCH API to delete the instance by its selectors:

{
  "productType": "PRODUCT",
  "patches": [
    {
      "op": "delete",
      "path": "/attributes/fulfillment_availability",
      "value": [
        {
          "fulfillment_channel_code": "AMAZON_NA"
        }
      ]
    }
  ]
}

This ^^^ would remove the AMAZON_NA (FBA) fulfillment channel code from the listing.

chapmanjw commented 2 years ago

@NetrushAbhijit @NetRushJacob, expanding on @hinavinayak's answer, the Seller Central Add/Edit Product and Excel templates experiences only allow for a listing to be DEFAULT MFN or FBA, not both. These experiences will remove one when you provide the other. The APIs do not do this for you, allowing you to be more explicit about what you actually want the API to do. This is similar to the SwitchFulfillmentTo option on the XML availability feeds.

Given that the the SwitchFulfillmentTo (and UI/Excel) use-case is common, we are looking into allowing a single PATCH API request perform the switch (i.e. delete AMAZON_NA at the same time as providing DEFAULT). I will update this thread once we dive into that further. Thanks.

shirushi-dev commented 2 years ago

@chapmanjw Has there been any progress on this proposal?

shirushi-dev commented 2 years ago

It is very inconvenient to have to make two requests to update "fulfillment_availability"; it would be useful to be able to change it with a single request.

shirushi-dev commented 2 years ago

Have you made progress?

chapmanjw commented 2 years ago

@NetrushAbhijit, @NetRushJacob, @shirushi-dev: We have implemented support for providing multiple patches on the same attribute (assuming they do not conflict with each other). So, for example, this is now supported:

{
  "productType": "PRODUCT",
  "patches": [
    {
      "op": "replace",
      "path": "/attributes/fulfillment_availability",
      "value": [
        {
          "fulfillment_channel_code":"DEFAULT",
          "quantity":0
        }
      ]
    },
    {
      "op": "delete",
      "path": "/attributes/fulfillment_availability",
      "value": [
        {
          "fulfillment_channel_code":"AMAZON_NA"
        }
      ]
    }
  ]
}
happy-bear-x commented 1 year ago

@chapmanjw Hello, I want to delete 'discounted_price' according to your content, but Error. How can I do that? send:

{
"patches": [
{
"op": "delete",
"path": "/attributes/purchasable_offer",
"value": [
{
"discounted_price": [
{
"schedule": [
{
"end_at": "2023-02-27T08:00:00.000Z",
"value_with_tax": 8.27,
"start_at": "2023-02-26T08:00:00.000Z"
}
]
}
]
}
]
}
],
"productType": "PRODUCT"
}

receive:

{
sku: xxxx
status: INVALID
submissionId: f75b963e30a243b98aae86ccc5806323
issues: [class Issue {
code: 4000000
message: An internal error has occurred. Please try again.
severity: ERROR
attributeNames: null
}]
}
alixleger commented 1 year ago

@chapmanjw Hello, I want to delete 'discounted_price' according to your content, but Error. How can I do that? send:

{
    "patches": [
      {
          "op": "delete",
          "path": "/attributes/purchasable_offer",
          "value": [
              {
                  "discounted_price": [
                      {
                          "schedule": [
                              {
                                  "end_at": "2023-02-27T08:00:00.000Z",
                                  "value_with_tax": 8.27,
                                  "start_at": "2023-02-26T08:00:00.000Z"
                              }
                          ]
                      }
                  ]
              }
          ]
      }
  ],
    "productType": "PRODUCT"
}

receive:

{
    sku: xxxx
    status: INVALID
    submissionId: f75b963e30a243b98aae86ccc5806323
    issues: [class Issue {
        code: 4000000
        message: An internal error has occurred. Please try again.
        severity: ERROR
        attributeNames: null
    }]
}

@happy-bear-x Hi, I have the same problem, do you know now how to do that ?

happy-bear-x commented 1 year ago

@chapmanjw Hello, I want to delete 'discounted_price' according to your content, but Error. How can I do that? send:

{
    "patches": [
        {
            "op": "delete",
            "path": "/attributes/purchasable_offer",
            "value": [
                {
                    "discounted_price": [
                        {
                            "schedule": [
                                {
                                    "end_at": "2023-02-27T08:00:00.000Z",
                                    "value_with_tax": 8.27,
                                    "start_at": "2023-02-26T08:00:00.000Z"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "productType": "PRODUCT"
}

receive:

{
    sku: xxxx
    status: INVALID
    submissionId: f75b963e30a243b98aae86ccc5806323
    issues: [class Issue {
        code: 4000000
        message: An internal error has occurred. Please try again.
        severity: ERROR
        attributeNames: null
    }]
}

@happy-bear-x Hi, I have the same problem, do you know now how to do that ?

Patch again. Invalidate ’end_at‘. ex:

{
    "patches": [
        {
            "op": "REPLACE",
            "path": "/attributes/purchasable_offer",
            "value": [
                {
                    "marketplace_id": "ATVPDKIKX0DER",
                    "our_price": [
                        {
                            "schedule": [
                                {
                                    "value_with_tax": 8.28
                                }
                            ]
                        }
                    ],
                    "discounted_price": [
                        {
                            "schedule": [
                                {
                                    "end_at": "2023-05-24T08:00:00.000Z",
                                    "value_with_tax": 8.27,
                                    "start_at": "2023-05-23T08:00:00.000Z"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "productType": "PRODUCT"
}

Then we can assume that the discounted_price has been removed. Api can see it, amazon listing manage can not see it

chrislan815 commented 1 year ago

@NetrushAbhijit, @NetRushJacob, @shirushi-dev: We have implemented support for providing multiple patches on the same attribute (assuming they do not conflict with each other). So, for example, this is now supported:

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

omg i think this is what i've been looking for... testing.