To Developers: @CS-Cart_team
Here is a resulting API GET http://host/api/2.0/features/500:
An empty feature (variants) list:
{
“feature_id”: “500”,
“feature_code”: “”,
“company_id”: “1”,
“feature_type”: “S”,
“parent_id”: “0”,
“description”: “Color ChipType 0”,
“internal_name”: “Color ChipType 0”,
“lang_code”: “jp”,
“status”: “A”,
“position”: “0”,
“purpose”: “group_variation_catalog_item”,
“feature_style”: “dropdown_images”,
“filter_style”: “checkbox”,
“variants”: []
}
A feature (variants) list (sa list above) that contains two variants:
{
“feature_id”: “500”,
“feature_code”: “”,
“company_id”: “1”,
“feature_type”: “S”,
“parent_id”: “0”,
“description”: “Color ChipType 0”,
“internal_name”: “Color ChipType 0”,
“lang_code”: “jp”,
“status”: “A”,
“position”: “0”,
“purpose”: “group_variation_catalog_item”,
“feature_style”: “dropdown_images”,
“filter_style”: “checkbox”,
“variants”: {
“1970”: {
“variant_id”: “1970”,
“variant”: “00 WHITE”,
“lang_code”: “jp”,
“feature_id”: “500”,
“position”: “0”
},
“1971”: {
“variant_id”: “1971”,
“variant”: “01 WHITE”,
“lang_code”: “jp”,
“feature_id”: “500”,
“position”: “1”
}
}
}
Variants object structure: Those two JSON objects themselves are valid. However, in the second example, the “variants” field is an object, with variant IDs as keys. This structure is not wrong, but it might make iterating over the variants a bit (?) more complex. A common practice is to use an array of objects for such cases. My question is: WHY?