5

I have a controller that load order like this:

$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id);

Is there a way to get a customer e-mail address by load order by id like this?

1
13

Try this :

$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id);
$email = $order->getCustomerEmail();

To get Customer Id :

$customerId = $order->getCustomerId();
2
  • You should use DI for that instead of using the object manager directly – Matthias Kleine Jul 14 '17 at 15:13
  • You can inject Order Class Model in your controller __construct method and call in execute method. – Manish Bhojwani Jan 28 '20 at 16:49
1

Get Customer Id from order details and load your customer and you can get Customer Email.

UPDATE:

$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id);

$customerId = $order->getCustomerId();

1
  • how to get the customer id and then the customer email? – simple guy Feb 2 '17 at 5:01

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.