Search This Blog

Wednesday, January 30, 2013

Really apply Magento Catalog rules

One of the things the regular cron jobs to is to reapply the catalog rules.
A symptom of the catalog rules not working is when the price of an item in a shopping cart doesn't have a sale price applied to it - was it does when viewing/searching for them from the catalog.

The cron entry in the config.xml file for the catalog in the rules should have:
    <crontab>
        <jobs>
            <catalog_product_index_price_reindex_all>
                <schedule><cron_expr>0 2 * * *</cron_expr></schedule>
                <run><model>catalog/product_indexer_price::reindexAll</model></run>
            </catalog_product_index_price_reindex_all>
        </jobs>
    </crontab>
</config>

This shows the catalog reindexAll method in product_indexer_price being called every hour.
If cron is working correctly this should be getting called.
I had an experience with a v.1.5.1.0 store where this wasn't happening and every so often the rules would not be applied.
The code below - which I added to a custom cron script applies the rules directly.


    /**
     * Apply all active catalog price rules
     */
try {
    Mage::getModel('catalogrule/rule')->applyAll();
    Mage::app()->removeCache('catalog_rules_dirty');
    echo  'The rules have been applied.';
    // added JMR 08-01-2013
    Mage::log("Cron apply rules run");
} catch (Exception $e) {
    echo 'Unable to apply rules.';
    Mage::log("Cron Unable to apply rules");
    Mage::printException($e);
}



10 comments:

  1. I am not certain the place you are getting your information, however great topic. I must spend some time learning more or working out more. Thanks for magnificent info I used to be looking for this information for my mission. https://www.facebook.com/hiremagentodeveloper

    ReplyDelete
  2. I think this is among the such a lot important info for me. And i am satisfied reading your article. However want to observation on some common issues, The web site style is perfect, the articles is really great

    Triple glazed wood windows

    ReplyDelete
  3. I believe that is among the most significant info for me. And i'm glad studying your article. However should remark on few common issues, The web site taste is wonderful, the articles is actually excellent : D. Just right job, cheers
    web design orlando

    ReplyDelete
  4. I'm extremely impressed along with your writing skills as smartly as with the structure for your blog. Is this a paid theme or did you modify it yourself? Anyway stay up the nice high quality writing, it is rare to see a nice weblog like this one today..web design dubai

    ReplyDelete
  5. I am not certain the place you are getting your information, however great topic. I must spend some time learning more or working out more. Thanks for magnificent info I used to be looking for this information for my mission. website design dubai

    ReplyDelete
  6. The post shared is worth to read and interesting for the newbies by all means for more knowledge - I was in search of such blog who explore my knowledge in the industry.for more knowledge-
    Jogging track

    ReplyDelete
  7. Hello There. I found your blog using msn. This is an extremely well written article. I'll be sure to bookmark it and come back to read extra of your useful information. Thank you for the post. I'll certainly comeback. link seo in philippines

    ReplyDelete
  8. Generally I do not read post on blogs, however I would like to say that this write-up very compelled me to take a look at and do so! Your writing taste has been surprised me. coaching classes in vadodara

    ReplyDelete
  9. Superb, what a weblog it is! This blog gives helpful information to us, keep it up.send sms from pc

    ReplyDelete
  10. Thanks for sharing as it is an excellent post would love to read your future post for more knowledge- I was in search of such blog who explore my knowledge in the industry.for more knowledge- Engineering colleges in vadodara

    ReplyDelete