require_once '../app/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name'=>'frontend'));
//$toDate = date('Y-m-d H:i:s', strtotime("-3 minutes"));
$toDate = date('Y-m-d H:i:s', strtotime("-96 hours"));
$orderCollection = Mage::getModel('sales/order')->getCollection()
->addAttributeToFilter('created_at', array('to'=>$toDate))
->addFieldToFilter('status', 'pending');
foreach($orderCollection as $_order)
{
$order = Mage::getModel('sales/order')->load($_order['entity_id']);
if($order->canCancel())
{
$order->cancel();
$comment = 'Order marked as cancelled';
$isCustomerNotified =true;
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, "canceled", $comment, $isCustomerNotified);
$order->save();
$order->sendOrderUpdateEmail(true, $comment);
}
}
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name'=>'frontend'));
//$toDate = date('Y-m-d H:i:s', strtotime("-3 minutes"));
$toDate = date('Y-m-d H:i:s', strtotime("-96 hours"));
$orderCollection = Mage::getModel('sales/order')->getCollection()
->addAttributeToFilter('created_at', array('to'=>$toDate))
->addFieldToFilter('status', 'pending');
foreach($orderCollection as $_order)
{
$order = Mage::getModel('sales/order')->load($_order['entity_id']);
if($order->canCancel())
{
$order->cancel();
$comment = 'Order marked as cancelled';
$isCustomerNotified =true;
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, "canceled", $comment, $isCustomerNotified);
$order->save();
$order->sendOrderUpdateEmail(true, $comment);
}
}
No comments:
Post a Comment