0

I'm on a mission to list all pending/processing and completed order lists on my external application from a Magento 1 site.

I learnt by using following code I can get all orders from the site. But how do i get order listing based on order status?

require_once 'app/Mage.php';
Mage::app();
$orders = Mage::getResourceModel('sales/order_collection');

foreach ($orders as $order):
    echo $order->getRealOrderId().' - '.$order->getCreatedAtStoreDate().' - 
('.$order->formatPrice($order->getGrandTotal()).')<br>';
endforeach;

Thank you,

2 Answers 2

1

Hello You can try this bit of code

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

You can try this below code

$orders = Mage::getModel('sales/order')->getCollection()
        ->addFieldToFilter('status', array('in' => array('complete','processing','pending_payment','canceled')));
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.