Magento 1.7 Catalog Price Rules – Reapplying Rules Programmatically

magento-1magento-1.7

I am facing a very strange problem of catalog price rules in magento. I have created catalog price rules to effect prices of product but sometime they automatically stop working then i have to reindex everything again and apply them again.
Now i am looking for permanent solution.
What i think the solution is to set a cron job and Re-Apply all the Catalog Price Rules through it. So how to Re-Apply all the Catalog Price Rules Programmatically ?

Has anybody also faced this problem ?

Thanks,

Best Answer

I had this before.
Because the catalog price rules have a start and end date, they need a constant reindex. (look in the tables catalogrule_product_*).
So when you apply all the rules they are valid for the current day only.
Magento already has a cron that applies the catalog rules that should run each day.
If you set up your cron to run this will be solved.
Add to your crontab:

*/5 * * * * /bin/sh /path/to/cron.sh