删除已取消的magento订单cron

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了删除已取消的magento订单cron相关的知识,希望对你有一定的参考价值。

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.
  1. <?php
  2.  
  3. require_once('app/Mage.php');
  4. Mage::app('admin');
  5. Mage::getSingleton("core/session", array("name" => "adminhtml"));
  6. Mage::register('isSecureArea',true);
  7. $collection = Mage::getResourceModel('sales/order_collection')
  8. ->addAttributeToSelect('*')
  9. ->setPageSize(5000)
  10. ->addFieldToFilter('status', 'canceled')->load();
  11.  
  12. foreach ($collection as $col) {
  13. Mage::log($col->getIncrementId() . ' order deleted ');
  14. try {
  15. $col->delete();
  16. } catch (Exception $e) {
  17. throw $e;
  18. }
  19. }

以上是关于删除已取消的magento订单cron的主要内容,如果未能解决你的问题,请参考以下文章

Magento 中的 PayPal 订单自动取消

如何在magento中使用付款方式取消订单

PayPal Checkout:取消已批准订单的正确方法

Magento 支付工作流程和事件订单已支付

如何从 Magento2 中删除测试订单

Magento 付款重定向订单