From f6374f000ff7b1263b8e959f48d1037ae9a462f4 Mon Sep 17 00:00:00 2001 From: Pascal Coste Demo Date: Wed, 8 Jan 2014 14:57:47 +0100 Subject: [PATCH] Added shell exec file to clean quotes from console --- .../Aoe/QuoteCleaner/Model/Cleaner.php | 13 ++++-- shell/aoe_quotecleaner.php | 40 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 shell/aoe_quotecleaner.php diff --git a/app/code/community/Aoe/QuoteCleaner/Model/Cleaner.php b/app/code/community/Aoe/QuoteCleaner/Model/Cleaner.php index c51ef6a..47d3083 100644 --- a/app/code/community/Aoe/QuoteCleaner/Model/Cleaner.php +++ b/app/code/community/Aoe/QuoteCleaner/Model/Cleaner.php @@ -6,15 +6,22 @@ class Aoe_QuoteCleaner_Model_Cleaner { * Clean old quote entries. * This method will be called via a Magento crontab task. * - * @param void + * @param Varien_Event_Observer $observer + * @param int $quoteDeleteLimit * @return void */ - public function clean() { + public function clean($observer = null, $quoteDeleteLimit = null) { $report = array(); $limit = intval(Mage::getStoreConfig('system/quotecleaner/limit')); - $limit = min($limit, 50000); + + //Differentiate between shell and crontab exec + if (false === is_null($quoteDeleteLimit)) { + $limit = min($quoteDeleteLimit, 50000); + } else { + $limit = min($limit, 50000); + } $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write'); /* @var $writeConnection Varien_Db_Adapter_Pdo_Mysql */ diff --git a/shell/aoe_quotecleaner.php b/shell/aoe_quotecleaner.php new file mode 100644 index 0000000..a017ef2 --- /dev/null +++ b/shell/aoe_quotecleaner.php @@ -0,0 +1,40 @@ +getArg('limit') && ((int) $this->getArg('limit') > 0)) { + $quoteDeleteLimit = (int) $this->getArg('limit'); + } + + echo "Start Aoe_QuoteCleaner\r\n"; + Mage::getModel("aoe_quotecleaner/cleaner")->clean(null, $quoteDeleteLimit); + echo "End Aoe_QuoteCleaner\r\n"; + } + + /** + * Retrieve Usage Help Message + */ + public function usageHelp() + { + return << Delete quote limit (max 50.000) + help This help + +USAGE; + } +} + +//Run Aoe QuoteCleaner Script +$shell = new Aoe_Shell_QuoteCleaner(); +$shell->run(); +