Apply Pricing Rules does not work

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.


Just adding this as it is something I just ran into.

Store has tons of SKUs and Catalog Price Rules. The rules weren't being applied, and after debugging cron and other things that have been a problem in the past, I took a look at the catalogrule_product_price table to see what was there. I saw a single entry:

enter image description here

Notice the value for rule_product_price_id -- Indeed, the max value for an INT(10) field. Reset your auto-increment and you should be good.