/ Published in: PHP
Say you don’t want to reset ALL your orders, maybe you want to PRUNE a production database. if that’s the case, this php file (added to a crontab, or ran from your magento root directory) will DELETE all cancelled orders (5000 limit per instance). This is helpful for production instances, to keep your magento running smoothly if you run alot of test transactions.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php require_once('app/Mage.php'); Mage::app('admin'); Mage::register('isSecureArea',true); $collection = Mage::getResourceModel('sales/order_collection') ->addAttributeToSelect('*') ->setPageSize(5000) ->addFieldToFilter('status', 'canceled')->load(); foreach ($collection as $col) { try { $col->delete(); } catch (Exception $e) { throw $e; } }
URL: http://www.magentocommerce.com/boards/vie/viewthread/2960/#t259879