3

programatically fetch the magento updated orders list in magento1.9

Thanks

  • Which orders you want? All orders? – Sukumar Gorai Aug 22 '18 at 11:56
  • Yes i want all orders using date – shivashankar m Aug 22 '18 at 11:56
  • You mean withing date range. Right? – Sukumar Gorai Aug 22 '18 at 11:57
  • Yes @sukumar do you have any idea – shivashankar m Aug 22 '18 at 11:58
  • Please check my answer. – Sukumar Gorai Aug 22 '18 at 12:01
1

You can try the following code:

$fromDate = date('Y-m-d H:i:s', strtotime($fromDate)); //From date
$toDate = date('Y-m-d H:i:s', strtotime($toDate)); // To date


$orders = Mage::getModel('sales/order')->getCollection(); // All Order collection
$orders->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate)); // Filter by date range

Updated Code:

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();
ini_set('max_execution_time', 3600);


$fromDate = date('Y-m-d H:i:s', strtotime('2018-05-01')); //From date
$toDate = date('Y-m-d H:i:s', strtotime('2018-05-31')); // To date


$orders = Mage::getModel('sales/order')->getCollection(); // All Order collection
$orders->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate)); // Filter by date range
if(count($orders) > 0){
    foreach($orders as $order){
        echo '<pre>';
        print_r($order->getData());
        echo '</pre>';
    }
}
?>

I have created one file in the root magento called getorders.php and place the above code. Run it and it works fine.

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.