Magento - how to get an email address through order / customer_id

How do I get a customer email address in Magento? In the end, I want to export all the delivery data in CSV format.

<?php //External script - Load magento framework require_once("app/Mage.php"); Mage::app('default'); $myOrder=Mage::getModel('sales/order'); $orders=Mage::getModel('sales/mysql4_order_collection'); $allIds=$orders->getAllIds(); foreach($allIds as $thisId) { $myOrder->load($thisId); echo "name: ". $myOrder->getShippingAddress()->getFirstname() . " " . $myOrder->getShippingAddress()->getLastname(); echo "email: " . $myOrder->getPayment()->getOrder()->getEmail(); } ?> 
+4
source share
3 answers

You can use:

 echo "name: ". $myOrder->getCustomerName(); echo "email: " . $myOrder->getCustomerEmail(); 

(tested in magento 1.6.2.0)

+21
source

As I recall, the email address is also saved with the delivery / payment information, therefore:

 $myOrder->getShippingAddress()->getEmail() 
+1
source

Use the following code to use the email address using the client’s client identifier:

  $orderId = '100000023'; // mention order id here $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); $shippingAddress = $order->getShippingAddress(); echo $shippingAddress->getEmail(); 
+1
source

Source: https://habr.com/ru/post/1400030/


All Articles