Magento – Apply Pricing Rules does not work

catalog-price-rulesmagento-1.9price-rulespromotions

Under my Catalog Price Rules we have a daily special being applied to 2 categories. The issue we're having is at the top of the page we see:

There are rules that have been changed but were not applied. Please, click Apply Rules in order to see immediate effect in the catalog.

Clicking apply executes for a very long time. I extended the php execution and apache timeouts so there is no 500 returned, however, the apply button just doesn't appear to function at all. I really wish I had more information on this issue, but nothing shows up in the system.log or exception.log.

If anyone has any insight into what might cause this function to hang indefinitely, it would be greatly appreciated.

Best Answer

We have the same problem, we use a PHP script to apply the Catalog Price Rules with the following PHP script (placed in the shell directory):

<?php require_once '../Mage.php'; ini_set('display_errors', 1);
#Varien_Profiler::enable();

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 $e) {
            echo Mage::helper('catalogrule')->__('Unable to apply rules.');
            print_r($e);
        }

Just run it with php nameofscript.php and the rules will be applied.