enter image description here

$customerID = $object->getCustomerId(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerObj = $objectManager->create('Magento\Customer\Model\Customer')->load($customerID);

2 Answers 2


Don't use the load, use the customer repository instead:

  $customerRepo = $objectManager->create('\Magento\Customer\Api\CustomerRepositoryInterface');
$customer = $customerRepo->getById(1);

You should be able to do


Or, if it is a custom attribute, just look in the custom_attributes, like this:


Whats your purpose in getting the Customer object, if in a module, in Magento 2 there are different ways to get the customer object, like by injecting the customer repository?

If you are creating a custom API, there is a different way to get the customer Object like through an access token.

But you should not Object Manager to get the Customer Object, you can use The Magento dependency injection mechanism enables you to override the functionality of the Magento_Customer module.

Api repository

protected $_customerRepositoryInterface;
public function __construct(
 \Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface,
) {
 $this->_customerRepositoryInterface = $customerRepositoryInterface;

Call the function:

$customerId = 1;
$customer = $this->_customerRepositoryInterface->getById($customerId);

Your Answer

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

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