I've just started with Magento 2, but I have few question why try to get customer data from event observer.

Here is what I'm using inside my observer. And the event is adminhtml_customer_save_after $this->_xmlGenerator->saveCustomerToXml($observer->getEvent()->getCustomer());

It is return an object from Magento\Customer\Model\Data. And this make my concernation. I can't find anything related to something like getPhone() inside the codebase.

And how to get specified address from getAddresses()

Do you have any suggestions for me?

2 Answers 2


Your question is a bit unclear but if you want the customer from the event adminhtml_customer_save_after then I suggest You try this code in your observer

* @var \Magento\Customer\Api\Data\CustomerInterface $customer
$customer = $observer->getEvent()->getData('customer');

You can access attributes like addresses with this:


I hope this is the answer you were searching for.


in your observer write below code

$event = $observer->getEvent();
$customerData = $event->getCustomer();

foreach ($customerData->getAddresses() as $address)

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.