I have created customer custom attribute 'segments' with the below options:

Options: SME, Reseller, Others

I want get segments value with text based on the customer id in magento2.

How to achieve this.

Thanks in Advance :-)

1 Answer 1


You can get value and text by using this code:


$customerId = 12;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customer = $objectManager->create('Magento\Customer\Model\Customer')->load($customerId);

//Get segments value
$segmentsValue = $customer->getCustomAttributeText('segments')->getValue();

//Get segments text
$segmentsText = $customer->getResource()

echo $segmentsText;
  • Is this a Magento 2 solution? I got Call to undefined method Magento\Customer\Model\Data\Customer::getCustomAttributeText() Feb 16 at 15:30

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.