I have looked through about 50 posts on this and still can’t find an answer. If catalog price rules for promotions need scheduled tasks, and a crontab to be setup, then please tell me what file needs to be executed from a cron job to make this work? Seriously, all I want to do is get catalog pricing rules to work, and I know this is the sticking point.
Also, what is the difference between me setting something up in my own crontab to run, and the scheduled tasks that should be running as setup through the configuration? There appears to be a major disconnect in the knowledge base on this particular point.
@chiaraweb: you are correct, running cron.php from browser would simulate cronjob.
But only once.
cron.php will generate scheduled tasks, clean history and run pending tasks that are not later than 15 minutes (by default) from their scheduled time.
Catalog rule updates are configured to be ran at the beginning of every hour, so it would require you to run cron.php in your browser not earlier than 15 minutes to next hour.
Also, the schedules are generated for 20 minutes (by default) ahead, which means you will not find the schedule for catalog rule updates in db table (cron_schedule) if you ran cron.php before 20 minutes prior to next hour.
The configuration is explained in the wiki article mentioned above.
If the cron.php is setup in crontab to run every 5 minutes, there would be better chance on catching the correct time to run catalog rule updates.
See in `cron_schedule` table for currently scheduled tasks. The name of catalog rule updates job is “catalogrule_apply_all”
I just wanted to clarify something here, and that is that there are probably 10+ members who have linked to the wiki article at the wrong URL throughout the forums as recent as a few weeks ago. Seriously, folks, check your links! It took me over an hour to discover that there is actually a wiki article on this subject, and it exists here:
I updated the broken link to point to the correct wiki article.
As far as the crontab is concerned, after actually reading the documentation, I had no problems setting it up correctly. I’m not a huge fan of the implementation, but it is what it is. I would also suggest that you double-check your memory limits, since I received an error that my memory had been exhausted after running the jobs. Although I have not tried it yet, the best solution for that problem I believe can be found here (read the last entries):
A little information on the crontab in regards to e-commerce for those curious…
A crontab is a Unix-like system (Unix/BSD/Linux) specific process that runs cron jobs at periodic intervals. Please note that Windows does not have a crontab, but instead has scheduled tasks that can be setup via the Windows Scheduled Task Wizard. You do not need IIS in order to run a scheduled task in Windows. Even if you run Apache on Windows, you still need to use a scheduled task, as they are OS specific, and not Web server specific.
In traditional e-commerce systems there are typically several cron jobs setup to run in the crontab. Most will hit a shell script (which in turn calls a class file that runs), but some just hit a script (like a .php file), which prompts the code to execute within that script. This is absolutely required for any robust e-commerce systems. Some examples of scripts that would be executed by cron jobs for an e-commerce storefront:
* Export all orders into an XML file every 15 minutes (which might be retrieved via SFTP by a third-party fulfillment provider).
* Import all products once every day, updating stock status, inventory, product attributes, etc.
* Update products in the catalog every 5 minutes with any special pricing based upon promotions setup in the admin.
Depending on the size of the system there might be 50+ cron jobs or scheduled tasks. For this reason, Magento, (and other systems) instead hit a single script (like cron.php in the root of Magento), which then runs all tasks based upon what is in the XML configuration files. This makes it easier for users who are not technically inclined, and who do not wish to deal with constantly modifying the jobs that are run in the crontab. The core can be updated, and so long as the single cron job is setup to run in the crontab, then all scripts should run appropriately.
This is why catalog price rules need scheduled tasks. After adding a pricing rule, Magento will need to constantly check all products to see if they meet the conditions, and then update the pricing. Remember though, that you do not need to wait until your task runs to see if your promotion has been correctly applied. Disable cache in Magento, save and apply your promotion, then hit cron.php via the browser at http://www.yourstoreurl.com/cron.php. As Moshe pointed out above though, you still need to setup the cron job so that it periodically hits cron.php and updates all the scheduled tasks running.
@chiaraweb: you are correct, running cron.php from browser would simulate cronjob.
But only once.
cron.php will generate scheduled tasks, clean history and run pending tasks that are not later than 15 minutes (by default) from their scheduled time.
Catalog rule updates are configured to be ran at the beginning of every hour, so it would require you to run cron.php in your browser not earlier than 15 minutes to next hour.
Also, the schedules are generated for 20 minutes (by default) ahead, which means you will not find the schedule for catalog rule updates in db table (cron_schedule) if you ran cron.php before 20 minutes prior to next hour.
The configuration is explained in the wiki article mentioned above.
If the cron.php is setup in crontab to run every 5 minutes, there would be better chance on catching the correct time to run catalog rule updates.
See in `cron_schedule` table for currently scheduled tasks. The name of catalog rule updates job is “catalogrule_apply_all”
OK Moshe
I checked all and this is the situation
NEWSLETTER works! ... because the send instructions are in cron_scheduled table (attached)
but in that table… only newsletter was scheduled… no catalog discount rules exists
Cron works… this is clear but maybe I missing something else or in cron.php or in config.xml
this is cron.php
<?php /** ......
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */
require 'app/Mage.php';
Mage::app('admin');
if (!Mage::app()->isInstalled()) { echo "Application is not installed yet, please complete install wizard first."; }
// Only for urls // Don't remove this $_SERVER['SCRIPT_FILENAME'] = 'index.php';
“To execute all these configured tasks, the cron.php file located in the Magento root will need to be run periodically, for example every 5 minutes. Basically, this script will check if it needs to run any tasks, and if it needs to schedule any future tasks.”
From what I understand, regardless of whether it shows up or not in the list of scheduled tasks in the database, it is running properly. According to the wiki article, the catalog rules are run every hour. So even if you your cron job hits cron.php once every 5 minutes, it will only prompt to check if an hour has passed since the last catalog rules were updated. Also, if you have your default scheduled task settings, it will cleanup the success history every 60 minutes. That means even if the catalog rules task was listed at one point in the database, and completed successfully, you would not see it after cleanup happens.
If you are importing products and you are not seeing promotions, then I suggest you add one product manually, then create the promotion. When I apply a promotion to products after they were added manually, and clear my cache, then it applies it immediately.
but I have a cronjob that call cron.php every 5 minutes
My products are created new, and also the catalog rules for discounts, all is new, installation, virtual server, items, rules.
Everything else is the same. To be honest, I’m not sure if mine is running as it should. I have been able to get promos to show up, and my cron job is running, but I think like you, it is not updating the catalog pricing rules properly. I think mine update only when I apply the rules in the admin, and/or run the cron.php manually through the browser.
I get the sense that not many people use catalog pricing rule promotions extensively because they do not work as expected.
If you do get any progress on this though, and you are enlightened, can you please enlighten me as well