0

Example "developer" attribute of the type select contains

 ID - LABEL
 12 - junior
 13 - regular
 14 - senior

How to retrieve all labels ids and/or names for this attribute. I need something like that

$attribute = $this->attributeRepository->get($attributeCode); //load select attribute

$labelsNames = $attribute->getLabelNames();
$labelsIds = $attribute->getLabelsIds();
1
$attributeOptions = $this->attributeRepository->get($attributeCode)->getOptions();
$idsLabels = array();
foreach($attributeOptions as $attributeOption){
    $idsLabels[$attributeOption->getValue()] = $attributeOption->getLabel();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.