Skip to content

Wrong return type for getAttributeText($attributeCode) #11691

@diazwatson

Description

@diazwatson

When I pass the a multi-select attribute code to getAttributeText($attributeCode) I get an array instead of an string.

public function getAttributeText($attributeCode)

Actually I don't see anything wrong with it but the return tag should be updated accordingly.

Preconditions

  1. Magento CE 2.1.9 /2.2 with sample data.

Steps to reproduce

I guess the easiest way to reproduce it is by:

  1. Creating a multi-select attribute for a product and add few values.
  2. Add the attribute you just created to the attribute set Default
  3. Edit a product using that attribute set and select all attribute values.
  4. Then you could use (for example)

magento/module-catalog/view/frontend/templates/product/view/form.phtml

to output the attribute values:

print_r($product->getAttributeText('your-attribute-code-here'))

Expected result

I would expect the return to be a string type as the return type says.

Actual result

But the result is instead an array of attribute values.

screen shot 2017-10-24 at 14 40 05

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions