My script is working "fine" ... almost, quiet often skipping orders created around 00:00 -> 01:00 Asked server administrator, he confirmed the time (correct), checked timezone etc. What can cause this issue ? there is no magic in it so i'm confused ...

$torders = Mage::getModel('sales/order')
        ->addAttributeToSort('increment_id', 'DESC')
        ->addAttributeToFilter('created_at', array('from' => $from,'to' => $now))
        ->addAttributeToFilter('status', array('nin' => array('canceled')));


$fr = Mage::getModel('core/date')->date('Y-m-d');
$om = ' 00:00:00';
$from = $fr.$om;
$time = Mage::getModel('core/date')->timestamp(time());//-3600
$now = date('Y-m-d H:m:i', $time);

definitely everything is ... ok;


From what I can see, you're trying to get only the current day orders. Try this:

$from = Mage::getModel('core/date')->date('Y-m-d');
$from = $from . ' 00:00:00';

$now = Mage::getModel('core/date')->date('Y-m-d H:i:s');

$orders = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToFilter('created_at', array('from'=> $from, 'to'=> $now))
    ->addAttributeToFilter('status', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED))
    ->addAttributeToSort('increment_id', 'DESC')

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.