I am using customer repository interface, to fetch some values, of the customer.

I have added a custom attribute "Authnet_Account_Number".

I am trying to fetch the value of it by,

$customer = $this->_customerRepository->getById($customerId);
$authnetAccountNumber = $customer->getCustomAttribute("authnet_account_number");

But when I print $authnetAccountNumber,

it is showing value "object"


2 Answers 2


you can get Value of attribute by getValue function

$customer = $this->_customerRepository->getById($customerId);

$customer->getCustomAttribute('authnet_account_number') is always have object in return

i am sure it will work for you.

  • 1
    Not really. It can also return null Jan 31, 2020 at 14:43

See also using getCustomAttribute which is not recommended

Instead try

$authnetAccountNumber = $customer->getData('authnet_account_number');
// or
$authnetAccountNumber = $customer->getAuthnetAccountNumber();

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.