Feature request from dnadle, posted on GitHub Aug 11, 2016
Preconditions
- Magento 2.1.0
Steps to reproduce
- Add a product attribute with multiple select input type and define several options (values).
- Choose a sku set some values for the attribute.
- GET the sku with /V1/products/{sku}
- Wrap the returned JSON body with { "product":
<JSON GET result>
}.
- PUT the sku with /V1/products/{sku}
- Edit the JSON body and set the attribute value to
[]
(empty array).
- PUT the sku again.
Expected result
- The unchanged results of a GET should PUT without errors.
- A multi select attribute with a single option with id "123" selected should be sent as ["123"].
- Multiple options selected should look like ["123","456"].
- Putting a an empty array should clear all the selected options for the attribute.
Actual result
- Putting an unchanged GET returns errors on the multiselect attribute:
{ "message": "Error occurred during \"custom_attributes\" processing. Attribute \"occasion\" has invalid value. Invalid type for value: \"string\". Expected Type: \"string[]\"." }
- If the attribute has a single option, it is sent as "123", not ["123"].
- If the attribute has multiple options, it is sent as "123,456", not ["123","456"].
- Putting an empty array does not remove whatever options are selected.