magento / magento/magento2

Rest API create product attribute options - unable to set option value

Open
#36,939 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Issue: ready for confirmation Progress: ready for grooming Reported on 2.4.5 Triage: Dev.Experience
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.