'Etsy API error - "sku must be consistent across linked products"
I am trying to update my variations on a listing via this method...
listings/'.$listing_id.'/inventory
However, when I try to add a second SKU it gives me the error message that "SKU must be consistent across linked products."
I know it is possible to have a listingn with multiple SKUs in the variations because that is how we currently operate. We are just trying to move some functionality over to our Admin portal (i.e. changin the variations on listings).
Right now we use "Size" and "Sleeve Length" as varations.
I am able to create multiple "Sleeve Lengths" but when I try to add more than one size with a SKU, it errors out.
I have also linked a video here explaining the issue.
https://drive.google.com/file/d/1_dywrCfv0QjNzR2VyHqh5un7TXzuV5p8/view?usp=sharing
Any help that anyone can provide would be IMMENSELY appreciated.
This is the array I'm trying to send through.
$testarray= array(
[
'sku' => 'sku-1',
'property_values' => [
[
'property_id' => '52047899318',
'property_name' => 'Size',
'scale_id' => 30,
'scale_name' => '',
'value' => '0-3M White Onesie',
'value_id' => '117126874336'
],
[
'property_id' => '513',
'property_name' => 'Sleeve Length',
'value' => 'Short SL Onesie',
'value_id' => '774674484481'
]
],
'offerings' => [
[
'price' => 10,
'quantity' => 3
]
]
],
[
'sku' => 'sku-2',
'property_values' => [
[
'property_id' => '52047899318',
'property_name' => 'Size',
'scale_id' => 30,
'scale_name' => '',
'value' => '0-3M White Onesie',
'value_id' => '117126874336'
],
[
'property_id' => '513',
'property_name' => 'Sleeve Length',
'value' => 'Short SL Onesie',
'value_id' => '774674484481'
]
],
'offerings' => [
[
'price' => 10,
'quantity' => 3
]
]
]);
Solution 1:[1]
I know that this question is 2 years old but since I came across the same error while implementing Etsy api I wanted help the others by posting my findings.
Suppose your items have the following variations
Size:
M
L
Sleeve Length:
Long
Short
First thing that you have to know is that when sending property values you MUST send all the possible combinations. What that means is the following:
Size M -> Sleeve Length Long
Size M -> Sleeve Length Short
Size L -> Sleeve Length Long
Size L -> Sleeve Length Short
This is how will look like in your products array, notice how I omitted the skus for now:
[
{
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "M"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Short"
}
]
},
{
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "M"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Long"
}
]
},
{
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "L"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Short"
}
]
},
{
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "L"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Long"
}
]
}
]
Now, regarding skus suppose that we have the following:
sku-1 refers to Size M Sleeve Length Short
sku-2 refers to Size L Sleeve Length Long
We have no sku for Size M Sleeve Length Long and Size L Sleeve Length Short
Keeping that in mind our array will now look like this:
[
{
"sku": "sku-1",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "M"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Short"
}
]
},
{
"sku": "",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "M"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Long"
}
]
},
{
"sku": "",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "L"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Short"
}
]
},
{
"sku": "sku-2",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "L"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Long"
}
]
}
]
Last thing we have to do, since our sku is changing from variation to variation in our case it changes based on size and sleeve length, before sending data we have to tell etsy that the sku is changing depending on the property, and to do that we have to set the sku_on_property property.
In our case the sku changes based on property id 52047899318 and 513.
Basically our request body will look like this:
{
"products": [
{
"sku": "sku-1",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "M"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Short"
}
]
},
{
"sku": "",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "M"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Long"
}
]
},
{
"sku": "",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "L"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Short"
}
]
},
{
"sku": "sku-2",
"property_values": [
{
"property_id": "52047899318",
"property_name": "Size",
"value": "L"
},
{
"property_id": "513",
"property_name": "Sleeve Length",
"value": "Long"
}
]
}
],
"sku_on_property": [
52047899318,
513
]
}
I hope that at least this comment will be helpful to everyone that comes across this thread.
Small things that you have to keep in mind:
this is for Etsy api v3, if you work with etsy api v2, I think that the
sku_on_propertyshould be a comma separated string instead of an array of integers, example:"sku_on_property":"52047899318,513"If your price and/or quantity changes based on the variations, then you have to set also the property
price_on_propertyandquantity_on_propertyrespectively in the same way you did for the skus.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Garantees |
