I have a custom eav attribute on a product that is a of type dropdown. When the product is saved, the attribute is saved as the optionId. How do I get its label to be able to display it properly on the frontend.


  • I do not want to load the whole set of options for the attribute and loop through the find the matching one. I want to be able to get the label for the saved id value.
  • I have the attribute option id and the attribute code and can use them for query.

1 Answer 1


get the productdata by id or sku i am using getbyId

$productData = $this->productRepository->getById($productId);

$attributeValue = $productData->getAttributeText("attribute_code");//pass your attribute code 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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