Magento – CatalogRule not appearing in cron_schedule table

catalog-price-rulescatalog-rulesce-1.9.0.1cronmagento-ce

I am on Magento CE 1.9.0.1

I sat a Catalog Price Rule, saved and applied it, and it works correctly.
Anyway, after a day it disappear.
I understood the cron logic, and went to check the cron_schedule table.
I have these rows

captcha_delete_expired_images
captcha_delete_expired_images
newsletter_send_all
newsletter_send_all
newsletter_send_all
newsletter_send_all
xmlconnect_notification_send_all
xmlconnect_notification_send_all
xmlconnect_notification_send_all
xmlconnect_notification_send_all

If i truncate the table and run the cron.sh script from mu ssh shell, the table gets populated again with the same rows. No CatalogRule row..

I also checked the various catalog rule tables and the rules are there..

What's (not) happening here?

Thank you!

Best Answer

you don't need to edit any of the cron files, it's not even recommended.

catalog rules do have some problems, but they can be solved directly or by adding an extra cronjob. the reason you're not seeing the cronjob in the db is because the job runs daily at 1:00 AM GMT and gets cleaned up after a few hours.

You can use n98-magerun to list your cron jobs, or http://fbrnc.net/blog/2011/03/magento-cron-scheduler#hello.

Like I said, catalog rules have some problems getting applied - most of the time they occur because of timezone issues - try changing the schedule.

Ultimately, you can create a new cronjob especially for this, but make sure you disable the default job.

Here's the file, call it catalogrule.php, put in shell/ then add a cronjob in your system executing it: php -f /full/path/to/magento/shell/catalogrule.php. You can also execute the file manually from the CLI, although that's probably not necessary.

<?php

require_once 'abstract.php';

class Mage_Shell_ApplyCatalogRules extends Mage_Shell_Abstract
{
    function run()
    {
        if ($this->getArg('h') || $this->getArg('help')) {
            die($this->usageHelp());
        }

        Mage::log('Started applying catalog rules', null, 'catalogrule.log', true);
        /** @var $resource Mage_CatalogRule_Model_Resource_Rule */
        $resource = Mage::getResourceSingleton('catalogrule/rule');
        $resource->applyAllRules();
        Mage::log('Ended applying catalog rules', null, 'catalogrule.log', true);
    }

    function usageHelp()
    {
        global $argv;
        $s = $argv[0];
        return <<<USAGE
Usage:  php -f $s
USAGE;
    }

}

$shell = new Mage_Shell_ApplyCatalogRules();
$shell->run();