Rest API create product attribute options - unable to set option value
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 12.2k
- Forks
- 9.4k
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions and environment
- Magento 2.4.5
- Having a custom product attribute, type multiple select
### Steps to reproduce
1. Create an attribute option using this REST API enpoint:
`POST products/attributes/{attributeCode}/options`
2. Use this payload:
```
"option": {
"label": "aaaaaaa",
"value": "bbbbb",
}
```
### Expected result
When I call this REST API endpoint:
`GET products/attributes/{attributeCode}/options`
in the result array I expect to obtain an option like this:
```
{
"label": "aaaaaaa",
"value": "bbbbb"
}
```
### Actual result
when the POST enpoint create the new option, it ignores the value. This is the created option:
```
{
"label": "aaaaaaa",
"value": "123"
}
```
where '123' is the progressive option ID.
### Additional information
Here is the official enpoint documentation:
https://adobe-commerce.redoc.ly/2.4.5-admin/tag/productsattributesattributeCodeoptions#operation/PostV1ProductsAttributesAttributeCodeOptions
as you can see **label** and **value** are mandatory, but value is totally ignored.
### Release note
_No response_
### Triage and priority
- [ ] Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._
- [ ] Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._
- [X] Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._
- [ ] Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._
- [ ] Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the POST request to products/attributes/{attributeCode}/options for a custom multiple-select attribute, then compare its response with GET products/attributes/{attributeCode}/options. Trace the REST endpoint and the option creation flow to find where the submitted value is replaced by the progressive option ID. Done means the requested value is preserved in the GET result and regression coverage verifies it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100