2

I'm trying to execute a cron (that disables certain products) on a per store basis, with timing set in the backend.

I have been looking at: http://inchoo.net/ecommerce/magento-configurable-cron/ and can get that working. But only for the default store. If I set one time in default settings and another time in store level settings, only the default runs.

My questions is, how do I apply this to multiple stores? Is there a way to give the cronjob the scope (storeID) it should run in the settings and how do I ensure the crontab picks all the times from different stores?

  • Have you looked at store emulation? You could iterate through and emulate each store you need to work on. – Jonathan Hussey Aug 26 '14 at 10:13
1

One solution I can think of is that you could set up separate different cron jobs for different stores, such that it one cron jobs deals with only one store id. You could just hard code the corresponding store's id in the cron job that is meant for the store.

From:

Mage_Cron_Model_Observer::_generateJobs($jobs, $exists)

 $cronExpr = Mage::getStoreConfig((string)$jobConfig->schedule->config_path);

From the above code it seems like it will always pick the config schedule from the default store than for each store, although I could be wrong.

  • Thx, that is definitely one way to go- but in this case it will be tough as there is a lot of different stores in this install. – dannevang Aug 26 '14 at 11:52
  • Is it necessary for you to run the cron job at different times for different stores. What is your reason for doing that? Can you not accomplish what you need to in one job that runs at the same time for all stores by looping through the set of stores one by one? – Paras Sood Aug 26 '14 at 11:56
  • No. It's disabling products based on a date variable and this should happen at different times. Example: In some stores the cut off time is at 11:00 and others at 13:00. – dannevang Aug 26 '14 at 12:32
  • 1
    Ok, well if you do find a better way for this that would be good. I'd also like to know how. But in case there isn't a work around you find, here is another idea: Make the 1 common cron run for all stores say every hour. Then as you loop through each store, check if it is about time for the store to run. If yes, then run rest of the cron for that store, else don't run the rest of the cron and loop continue to the next store. – Paras Sood Aug 26 '14 at 12:36

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.