get orderlist filter by status and lastupdated programatically magento


<?php
require_once('app/Mage.php');
Mage::app('admin');
Mage::getSingleton("core/session", array("name" => "adminhtml"));
Mage::register('isSecureArea',true);
$collection = Mage::getResourceModel('sales/order_collection')
->addAttributeToSelect('*');
//->addFieldToFilter('hpc_order_id', array('neq' => '',))
//->addFieldToFilter('hpc_order_from', array('eq' => 'ebay',)));


//->addFieldToFilter('status', 'complete')->load(); //pending,complete


//$collection->addAttributeToSort('created_at', 'desc');


$min_diff = '60';
$from_date = date("Y-m-d H:i:s", strtotime("-".$min_diff." minute"));
$to_date = date("Y-m-d H:i:s");
$collection->addAttributeToFilter('updated_at', array(
    'from' => $from_date,
    'to' => $to_date
    ));


/*
echo '<pre>';
print_r($collection);
echo '</pre>';
*/
echo "<br />supplement order start";
echo '<table border="1" style="1px solid #cccccc">';
 echo '<tr>';
  echo '<th>Order Id</th>';
  echo '<th>Order Created at</th>';
  echo '<th>Order Updated at</th>';
   echo '<th>Order State</th>';
   echo '<th>Order Status</th>';
   echo '<th>HPC Order ID</th>';
   echo '<th>HPC Order from</th>';
  echo '</tr>';
  
foreach ($collection as $col) {
    echo '<tr>';
        echo "<td>".$col->getIncrementId()."</td>";
        echo "<td>".$col->getCreatedAt()."</td>";
        echo "<td>".$col->getUpdatedAt()."</td>";
        echo "<td>".$col->getState()."</td>";
        echo "<td>".$col->getStatus()."</td>";
         echo "<td>".$col->getHpcOrderId()."</td>";
          echo "<td>".$col->getHpcOrderFrom()."</td>";
    echo '</tr>';
}
 echo '</table>';
 
echo "<br />supplement order ends";
?>

Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools