Tuesday, October 1, 2013

Magento – Delete all cancelled magento orders

$collection = Mage::getResourceModel('sales/order_collection')
            ->addAttributeToSelect('*')
            ->setPageSize(1000)
            ->addFieldToFilter('status', 'canceled')
     ->load();

foreach ($collection as $col) {
  Mage::log($col->getIncrementId() . ' order deleted ');
    try {
         $col->delete();
    } catch (Exception $e) {
        throw $e;
    }
}

No comments:

Post a Comment

Please mention your comments.......