I have customer entity id, how do i get customer attribute value by loading customer entity id, Please provide me a solution

2 Answers 2


you can use this code to get customer attribute value.

class MyClass 
        protected $_customer;
        protected $_customerFactory;

        public function __construct(...
               \Magento\Customer\Model\CustomerFactory $customerFactory,
               \Magento\Customer\Model\Customer $customers
            $this->_customerFactory = $customerFactory;
            $this->_customer = $customers;

        public function getCustomerCollection() {
            return $this->_customer->getCollection()

        public function getFilteredCustomerCollection() {
            return $this->_customerFactory->create()->getCollection()
                    ->addAttributeToFilter("firstname", array("eq" => "Max"))

That depends where you want that information, template, some module etc. you can use below code to get customer object data :

$id = xxx; // customer id
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerObj = $objectManager->create('Magento\Customer\Model\Customer')
$customerFirstName = $customerObj->getFirstName();

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.