Open
Description
Preconditions and environment
- Magento version 2.4.6-p3
Steps to reproduce
- Create attribute, dropdown, custom source model with :
[0 => ['value' => 1, 'label' => 'option A'], 1 => ['value' => 2, 'label' => 'option B']
- Create/save a product with attribute =
Option A
(value saved =1
) - Change your source model to remove first option
- dump
$attribute->getOptionText($product->getData('attribute'))
Expected result
Dumps null or false
Actual result
Dumps array :
['value' => 2, 'label' => 'option B']
Additional information
Use case :
It can happens quite easily with dynamic attribute source (when source options are managed via an UI for example)
Problem :
Fix could be :
if (is_scalar($value) && isset($options[$value]) && is_scalar($options[$value])) {
instead of
if (is_scalar($value) && isset($options[$value])) {
Or maybe remove that whole if : I don't understand why it exists.
Note : In my case, this issue crashed catalogsearch_fulltext reindex, leaving categories empty of products of frontend (but I'm using smile/elasticsuite)
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
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedA defect with this priority could have functionality issues which are not to expectations.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchIssue related to Developer Experience and needs help with Triage to Confirm or Reject it