//to get orders based on date range

 

$period_date_from = $this->getRequest()->getParam(‘report_from’);

$from_date = strtotime($period_date_from); // begin date
$period_date_to = $this->getRequest()->getParam(‘report_to’);
$to_date = strtotime($period_date_to); // begin date
$myOrder=Mage::getModel(‘sales/order’);
$orders=Mage::getModel(‘sales/mysql4_order_collection’);
$to_date = date(‘Y-m-d’ . ‘ 00:00:00’, $to_date);
$from_date = date(‘Y-m-d’ . ‘ 00:00:00’, $from_date);
$orders->addFieldToFilter(‘created_at’, array(‘from’=>$from_date, ‘to’=>$to_date));
$orders->addAttributeToSort(‘created_at’, ‘DSC’);

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *