How to create a cron job without admin panel in Prestashop

I am trying to create a simple new cron job for my module in Prestashop. Wherever I see this, I have to define my cron in the admin panel. But this seems silly because I will not write to every person who loads my module to activate this cron manually. I wrote cron jobs for wordpress and magento with no problem, but in Prestashop I can't find any tutorial when the process is described. Can cron be written and activated automatically?

thank

+3


source to share


1 answer


- Edited the inclusion of Victor Dramba's input -

For Prestashop "native" cronjob handler (version 1.3.2), the following applies:

You can make your module automatically install cronjob by including the following:

  • Register to the hook "actionCronJob"
  • Provide a public method getCronFrequency ()
  • Provide a public method actionCronJob ()

getCronFrequency should return an array that looks like this:



array('hour'=>1, 'day'=>-1, 'month'=>-1, 'day_of_week'=>1);

      

Values ​​-1 are equivalent to * in a Unix-style cronjob.

Be aware, however, that Basic mode "cron" jobs are run by a web service hosted by Prestashop itself. This means your site must be public, so you cannot easily test it in your usual localhost development environment.

Advanced cronjobs are not registered with the Prestashop webservice, so you can run them yourself via your own crontab manager.

+2


source







All Articles