I'm using the module Amasty's customer Attributes to create custom customer attributes, I like to get custom attribute displayed value but i got the option value. I like to get the value in data-title attribute enter image description here

I tried this

  if ($customAttribute = $customer->getCustomAttribute('custom_value')){
            $regrouper = $customAttribute->getValue();
            var_dump(regrouper);exit; //it returns 615 instead of 'Ok'

1 Answer 1


This is an ugly way of doing it but having been struggling myself doing it I ended up with this workaround creating this method that will take as parameter the getValue return.

If you found a better way of doing thing, please share :)

 * TODO Rework method with collection or repository ?
 * @param $option_id
 * @return string
public function getAttributeValueLabel($option_id){
    $connection = $this->resource->getConnection();
    $select = $connection->select()
            ['ol' => 'eav_attribute_option_value'],
        ->where('option_id = ?',$option_id);
    return $connection->fetchOne($select);
  • How to get option id? Commented Feb 16, 2022 at 20:05
  • 1
    As I said the option_id should match the value that is already returned by your custom attribute getValue 615 is actually the option id 615. You can pre check the request doing it by hand select * from eav_attribute_option_value where option_id = 615 and you should be able to retrieve the label data in the result request.
    – Claims
    Commented Feb 17, 2022 at 8:25
  • I contacted Amasty, i'm waiting for their answer, otherwise i tested you query and it returns the right result Commented Feb 17, 2022 at 16:13
  • Glad to hear it's working for you. It's not really amasty specific, the issue would be the same with every custom attribues. Now may be the people from amasty will came out with a better solution or even the right way of doing things. Hope !
    – Claims
    Commented Feb 17, 2022 at 16:22

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.