Sometimes you might want to update your catalog price rules at different times of the day, to make sure they’re applied. So, lets look at a script we can schedule and run through a cron task.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
require_once '../Mage.php'; Mage::setIsDeveloperMode(true); umask(0); Mage::app('default'); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); try { Mage::getModel('catalogrule/rule')->applyAll(); Mage::app()->removeCache('catalog_rules_dirty'); echo Mage::helper('catalogrule')->__('The rules have been applied.'); } catch (Exception $exception) { echo Mage::helper('catalogrule')->__('Unable to apply rules.'); echo $exception->getMessage(); } |
Image Credit: Bourguiboeuf
Comment or tweet @douglasradburn