Get order ids filtered by status in Magento

10 Jul

This can be run as a script from the base Magento install folder. If its running inside of a Magento file already (controller or block or whatever) you don’t need the first three lines.


$orders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('status', 'complete')
   // ->addAttributeToSelect('customer_email')
foreach ($orders as $order) {
    $email = $order->getCustomerEmail();
    echo $email . "\n";


To see all orders with statuses and emails:

$orders = Mage::getModel('sales/order')->getCollection()
    //->addFieldToFilter('status', 'complete')
foreach ($orders as $order) {
    $email = $order->getCustomerEmail();
    echo $order->getId() . ": '" . $order->getStatus() . "', " . $email . "\n";
Leave a comment

Posted by on July 10, 2013 in Magento



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: