I have had regard to the documents on how to update a feature via API Product Features — CS-Cart 4.18.x documentation the relevant bit being:
Update a Product’s Feature
Update a feature of a product using PUT /products/:id/.
Send the data in the body of the HTTP request. The data should comply with the content-type.
curl --header 'Content-type: application/json' -X PUT 'http://example.com/api/products/250' --data-binary {"product_features": {"23": {"feature_type": "T", "value": "Feature updated"}}}
This example request updates the product with product_id=250. It sets the value of the text feature with feature_id=23 to Feature updated.
In the response you receive the ID of the product.
{product_id: 250}
But I have been unable to have success. Here is the expected result (this is the feature data returned by the API after I have set it via admin panel)
{"features":[{"feature_id":"570","company_id":"0","feature_type":"S","parent_id":"0","display_on_product":"N","display_on_catalog":"N","display_on_header":"N","description":"identifier_exists","internal_name":"identifier_exists","lang_code":"en","prefix":"","suffix":"","categories_path":"","full_description":"","status":"A","comparison":"N","position":"0","purpose":"find_products","feature_style":"text","filter_style":"checkbox","feature_code":"identifier_exists","timestamp":"1720740617","updated_timestamp":"1720745404","group_position":null,"value":"","variant_id":"6848","value_int":null,"variants":{"6847":{"variant_id":"6847","variant":"no","description":"","page_title":"","meta_keywords":"","meta_description":"","lang_code":"en","feature_id":"570","url":"","color":"#ffffff","position":"0","selected":null,"feature_type":"S","seo_name":null,"seo_path":null,"image_pair":null},"6848":{"variant_id":"6848","variant":"yes","description":"","page_title":"","meta_keywords":"","meta_description":"","lang_code":"en","feature_id":"570","url":"","color":"#ffffff","position":"0","selected":"6848","feature_type":"S","seo_name":null,"seo_path":null,"image_pair":null}}}],"params":{"product_id":897,"category_ids":[],"statuses":[],"plain":true,"feature_types":[],"feature_id":0,"exclude_feature_id":0,"display_on":"","exclude_group":true,"exclude_empty_groups":false,"exclude_filters":false,"page":1,"items_per_page":500,"get_top_features":false,"top_features_limit":10,"existent_only":true,"variants":true,"variant_images":true,"variants_items_per_page":null,"variants_page":null,"variants_selected_only":false,"skip_variants_threshould":false,"variants_only":null,"get_descriptions":true,"sort_order":"asc","sort_by":"position","sort_order_rev":"desc","total_items":"1"}}
When I set it in the format specified by the documentation
{"product_features":{"570":{"feature_type":"S","value":"yes"}}}
It returns the product ID (indicating success) but it clears the feature set, and even if I start with the other variant or no variant, or try including “varaint_id:6847” in my json object I am unable to get the variant to update? I get this result every time …
{"features":[],"params":{"product_id":897,"category_ids":[],"statuses":[],"plain":true,"feature_types":[],"feature_id":0,"exclude_feature_id":0,"display_on":"","exclude_group":true,"exclude_empty_groups":false,"exclude_filters":false,"page":1,"items_per_page":500,"get_top_features":false,"top_features_limit":10,"existent_only":true,"variants":true,"variant_images":true,"variants_items_per_page":null,"variants_page":null,"variants_selected_only":false,"skip_variants_threshould":false,"variants_only":null,"get_descriptions":true,"sort_order":"asc","sort_by":"position","sort_order_rev":"desc","total_items":"0"}}