Closed alexisbellido closed 5 months ago
Hello,
I had a very similar use case I worked on recently. Unfortunately it seems the only way to remove a child from a variation family is to delete the family and recreate it without that child. Interacting with the "child_parent_sku_relationship" parameter using the "delete" operator had no effect on any of the listings I tried it on. I can share my code for patching a parent to add a child, however.
child_patches = []
if 'parentage_level' in child_data['attributes'].keys():
patch = {
'op': 'replace',
'path': '/attributes/parentage_level',
'value': [
{
'marketplace_id': marketplace_id,
'value': 'child'
}
]
}
child_patches.append(patch)
else:
patch = {
'op': 'add',
'path': '/attributes/parentage_level',
'value': [
{
'marketplace_id': marketplace_id,
'value': 'child'
}
]
}
child_patches.append(patch)
if 'child_parent_sku_relationship' in child_data['attributes'].keys():
patch = {
'op': 'replace',
'path': '/attributes/child_parent_sku_relationship',
'value': [
{
'marketplace_id': marketplace_id,
'child_relationship_type': 'variation',
'parent_sku': new_parent,
}
]
}
child_patches.append(patch)
else:
patch = {
'op': 'add',
'path': '/attributes/child_parent_sku_relationship',
'value': [
{
'marketplace_id': marketplace_id,
'child_relationship_type': 'variation',
'parent_sku': new_parent,
}
]
}
child_patches.append(patch)
child_patch_request = {
'productType': product_type,
'patches': child_patches
}
p = {
'marketplaceIds': [marketplace_id]
}
#headers['content-type'] = 'application/json-patch+json'
child_res = requests.patch(f'https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/{seller_id}/{sku}', params=p, data=json.dumps(child_patch_request), headers=headers, auth=auth)
child_patch_response = child_res.json()
return child_patch_response`
Thank you for sharing. I'm back to working on this and will report back with my findings.
And it looks like we have the same problem when trying to move a child from one parent to another. Just changing parent_sku in /attributes/child_parent_sku_relationship won't do anything, even if the patches are accepted by SP-API so for now the only alternative seems to be deleting the parent so that all children in the variation family can be free and reassigned to a new parent.
I'll welcome any other suggestions :)
+1
@alexisbellido @oliverjenkinsreli would you be able to share some code on how you create a parent sku through the api, and how do you delete the family as well? Stuck at the same point as both of you were a few months ago I think
Hi @fret423 Apologies for taking so long to respond. Here is some info that may help:
I had no success in creating Variation families automatically - unfortunately, in our workflow, we had to instead manually fill out the Update Product Details template from this link: https://sellercentral.amazon.com/listing/cards. There we could change the Variation details after we had deleted the previous Variation family. Then we used the SP-API Feeds endpoints in order to upload the document. There should be some documentation here: https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference
As for deleting a parent, this was done also through the SP-API, using the Listings endpoints:
def delete_sku(sku, headers, auth, seller_id, marketplace_id='XXXXXXXXXXXX'):
p = {
'marketplaceIds': [marketplace_id]
}
response = requests.delete(f'https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/{seller_id}/{sku}', params = p, headers = headers, auth = auth)
return response
I hope this helps!
Please reach out to developer support so that we can better help you with issues related to SP API.
Note: SP API or docs related issues / troubleshooting support is managed by a different team. We can help if the issue is related to the content published on this repo.
Hello, I've used the Listings Item API patchListingsItem operation to remove two variation-related attributes from one of my listings with the goal of making it an individual listing. The listing is currently a child in a variation set I created on Seller Central and I read that I had to remove the /attributes/parentage_level and /attributes/child_parent_sku_relationship attributes and that's why the patches I passed to patchListingsItem look like this:
After I made the call I got a response like this:
It's been a couple of hours since I made this API call and I still don't see any change, my listing is still a child in the variation set. What am I missing? What's the correct way of using SP-API to remove a listing from a variation?
I'd also appreciate it if you could tell me how to do the reverse, adding an individual listing as a child in an existing variation set.
Thank you.