I’m POSTing configurable products via REST API, meaning if I have a t-shirt in 3 sizes and there’s a custom “size” attribute I need to do 4 POST requests: 3 virtual ones for “S”, “M” and “L” sizes and 1 main container product.
For virtual products I provide the reference to our custom size attribute via this JSON fragment:
"custom_attributes" :
[
{
"attribute_code" : "category_ids",
"value" : [ "3", "4" ]
},
{
"attribute_code" : "product_brand",
"value" : "1"
},
{
"attribute_code" : "size_international",
"value" : "55"
}
],
where “55” is the unique identifier within the attributes system pointing to, say, size “L”.
The question is, why must I reference this attribute again in configurable product’s REST like this:
"configurable_product_options": [
{
"id": 421,
"attribute_id": "193",
"label": "Size International",
"position": 0,
"values": [
{
"value_index": 50
},
{
"value_index": 51
},
{
"value_index": 52
},
{
"value_index": 53
},
{
"value_index": 54
},
{
"value_index": 55
}
],
"product_id": 1162
}
Why can’t Magento simply rely on whatever size ids were specified in related virtual products? What are the “values” for and why must they be unique according to the documentation? I was under impression that configurable product was mostly a container and all variables like size and color options would only belong in virtual products.
If I do a POST request without the configurable_product_options block, I get an error saying that two of my products have the same attribute values, therefore POST fails.