1

I want/need to overwrite a core cronjob (app/code/core/Mage/Sitemap/Model/Observer.php). For some reason cronjobs, which are stored in core_config_data, don't get triggered. So I was thinking to trigger it with my own extension (temporarily). Is this possible? It looks like Magento doesn't find the module Mage/sitemap and is looking in my own extension for the model/observer. Thank you!

Core config.xml

<crontab>
    <jobs>
        <sitemap_generate>
            <run>
                <model>sitemap/observer::scheduledGenerateSitemaps</model>
            </run>
        </sitemap_generate>
    </jobs>
</crontab>

My_module config.xml

<crontab>
<jobs>
   <sitemap_generate>
      <module_name>
        <schedule>
            <cron_expr>0 3 * * *</cron_expr>
        </schedule>
        <run>
            <model>sitemap/observer::scheduledGenerateSitemaps</model>
        </run>
      </module_name>
   <sitemap_generate>
</jobs>

1

Yes it is possible to run other modules cron jobs using the code that you have specified. What happens when processing the cron is that Magento will end up running the function Mage::getModel('sitemap/observer) and then running the function scheduledGenerateSitemaps on this model.

What you can do is:

1) Check that you have the cron.sh or cron.php set-up to run on your server. 2) Add a dependancy between your module and sitemap module. This will show you if one of the modules is disabled but you need it to work. 3) Check your logs and exceptions and the cron should through one of the two following errors during processing.

Mage::throwException(Mage::helper('cron')->__('Too late for the schedule.'));
Mage::throwException(Mage::helper('cron')->__('Invalid callback: %s::%s does not exist', $run[1], $run[2]));
Mage::throwException(Mage::helper('cron')->__('Invalid model/method definition, expecting "model/class::method".'));

These can be found on the table cron_schedule under the messages column.

  • Hey David, thank you so much for your answer. So at least I know it supposed to work. Unfortunately it doesn't work for me. I even don't see any exceptions. Its probably something wrong with the cache. – Stefan Jan 19 '15 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.