Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listings API patchListingsItem operation possible fulfillment_channel_code replace issue #2061

Closed
NetrushAbhijit opened this issue Nov 24, 2021 · 12 comments
Assignees

Comments

@NetrushAbhijit
Copy link

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
Copy link

@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
Copy link
Contributor

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 chapmanjw self-assigned this Jan 18, 2022
@chapmanjw
Copy link

@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
Copy link

@chapmanjw
Has there been any progress on this proposal?

@shirushi-dev
Copy link

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
Copy link

Have you made progress?

@chapmanjw
Copy link

@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
Copy link

happy-bear-x commented Feb 28, 2023

@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
Copy link

@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
Copy link

happy-bear-x commented May 25, 2023

@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
Copy link

@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.

@shreeharsh-a shreeharsh-a transferred this issue from amzn/selling-partner-api-docs May 24, 2024
@enochlev
Copy link

enochlev commented Dec 1, 2024

Is there a way to decrement listing? Like what if a listing was sold within the 15min time window to update? I can see there is room for race conditions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants