magento2: Can not update attribute options label via REST Api.
Preconditions (*)
- Magento 2.3.x
Steps to reproduce (*)
- Create a dropdown type product attribute from admin.
- Add some attribute options.
- Save it.
- Get admin token by rest request
https://i-22554-2-3-develop.instances.magento-community.engineering/rest/V1/integration/admin/token
- Now update option label like:
URL: https://i-22554-2-3-develop.instances.magento-community.engineering/rest/V1/products/attributes/color/options
Request type: POST
BODY: { "option": { "value": "4", "store_labels": [ { "store_id": 0, "label": "Yellow2" } ] } }
Expected result (*)
- Attribute option label must be update with new label.
Actual result (*)
- It creates new option with given label for update.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (8 by maintainers)
You can update option, but you need to mention the “option id” which has the field key “value”.
Endpoint: PUT /rest/all/V1/products/attributes/[your attribute code]
After called, go back to your Magento backend, you will see the option is updated but not created.
@magento-engcom-team , why we are adding prefix 'id_’ in option id here https://github.com/magento/magento2/blob/2.3.1/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php#L163 ??