Skip to content

Attribute Option Label Gets Overwritten When Updating Store Labels #40093

@subashn9594

Description

@subashn9594

Preconditions and environment

  • Magento 2.4.7-p6

  • Product attribute with multiple store_labels (e.g., for France and Germany)

  • Asynchronous or sequential update of attribute option using:
    PUT /rest/all/async/bulk/V1/products/attributes/byAttributeCode/options/byOptionId

  • Magento’s implementation of the saveOption() method in \Magento\Eav\Model\Entity\Attribute\OptionManagement overwrites existing store-specific labels (store_labels) when an update is made, instead of merging the changes. As a result, labels for other store views are unintentionally removed when not explicitly included in the update payload.

Steps to reproduce

  1. Create or ensure a product attribute option has the following setup:
  • option_id = 1234
  • Labels:
    - Store ID 2 (France): "Bleu"
    - Store ID 3 (Germany): "Blau"
  1. Call the API to update only the French label:
{
  "option_id": 1234,
  "store_labels": [
    {
      "store_id": 2,
      "label": "Bleu updated"
    }
  ]
}
  1. Next call, update only the German label:
{
  "option_id": 1234,
  "store_labels": [
    {
      "store_id": 3,
      "label": "Blau updated"
    }
  ]
}
  1. Observe that after the second update, the French label is removed (set to blank)

Expected result

  • The store_labels for France should remain intact after the Germany label is updated.
  • Magento should merge the provided labels with existing ones instead of fully overwriting them.

Actual result

The second update overwrites the entire set of store_labels, removing any store-specific labels not included in the request.

Additional information

The method \Magento\Eav\Model\Entity\Attribute\OptionManagement::saveOption() constructs a new options['value'][$optionId] array and replaces all existing labels. There is no merging logic, and missing labels are effectively erased.

Relevant code snippet:
$options['value'][$optionId][0] = $optionLabel; foreach ($option->getStoreLabels() as $label) { $options['value'][$optionId][$label->getStoreId()] = $label->getLabel(); }

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.
  • 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”.

Metadata

Metadata

Assignees

Labels

Area: APIsComponent: AttributesIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Reported on 2.4.7-p6Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

Status

Ready for Development

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions