I'm having an issue with getting data from custom column I added in customer_entity. I added a column typo3_password in UpdateSchema.php and now I need to get data from this column. Trying to do that using getTypo3Password() method and adding CustomerInterface in module's Api\Data but it doesn't work.

 $customer       = $this->customerRepository->get($username);
 $customerId     = $customer->getId();
 $typoHashFromDb = $customer->getTypo3Password();

Any ideas? Do I need to add my custom Customer Model as well?

-- edit

Adding the custom CustomerInterface I created.

 const TYPO3_PASSWORD = 'typo3_password';

 * Get Typo3 Password
 * @return string|null
public function getTypo3Password();

 * @param string $typo3password
 * @return $this
public function setTypo3Password($typo3password);

The customer entity is an EAV entity, and a customer's properties are organized with attributes in the table eav_attribute.

After you added a customer attribute, you don't have to create a getter or a setter. Magic methods will take care of it, and getTypo3Password() will automatically be available.

You can also use getData('typo3_password').

  • Thanks, but doesn't really work. I'm not adding an attribute in eav_attribute, but instead I'm adding a column in customer_entity table in database and want to get the data out of this column. Any ideas with this? Nov 15 '16 at 19:48
  • 1
    This is the completely wrong approach. You should use an attribute, Magento EAV entities work this way. I don't know how it could work with a column; and I don't know why anyone should want this. ;) Nov 15 '16 at 19:51

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.