5
votes

Shopping cart price rules are causing significant slowdowns in Add to Cart and Checkout buttons.

I've found the issue addressed in two places with two different solutions:

http://www.magentocommerce.com/answers/discussion/1997/Huge-performance-problem-with-shopping-cart-price-rules-in-large-volumes-3000-5000-coupons/p1

I tried the above by creating a local copy of app/code/local/Mage/SalesRule/Model/Rule/Condition/Product.php and over wrote the validator function with:

 public function validate(Varien_Object $object)
{
    if(!Mage::registry("rule_condition_product_".$object->getProductId()))
    {
        $product = Mage::getModel('catalog/product')
                    ->load($object->getProductId());
        Mage::register("rule_condition_product_".$object->getProductId(),$product);
    }

        $product = Mage::registry("rule_condition_product_".$object->getProductId());

        $product->setQuoteItemQty($object->getQty())
                ->setQuoteItemPrice($object->getPrice())
                ->setQuoteItemRowTotal($object->getRowTotal());

    return parent::validate($product);
}

there was no improvement in performance

the other suggested solution is:

http://www.neptuneweb.com/blog/29-improving-magento-checkout-performance-with-large-number-of-cart-rules.html

this suggests overriding the product->load() function but I'm not clear how/where they are suggesting to do this. I presume it is not a local version of app/code/core/Mage/Core/Model/Abstract.php

Any thoughts?

1

1 Answers

0
votes

The best way to address sluggish performance of add to cart or checkout pages is by enhancing the cache mechanisms that Magento uses. From my experience, the best way to achieve super fast checkout pages is by replacing the built in Magento's cache with an external cache server like redis.

It is true that cart and checkout related performance seems to deteriorate with additional Price Rules, mainly due to Magento's architectural design in this area. Magento creates a new record for every product price X customer groups X price rules X tier pricing (and more). So, if you have a large catalog to begin with and dozens or hundreds of customer groups and dozens of hundreds of price rules, the price table grows exponentially and the checkout suffers on multiple levels. Hopefully this will get addressed, but unlikely soon. Redis is your friend.

Another option is to allow add to cart or checkout and record the transaction in a queue and process the actual order later in a producer/consumer fashion. I'm familiar with this first hand, and it's a great way to go for extremely large transactional websites but it also introduces some challenges as well.

If you are on Magento 1.8.x.x CE or higher: Redis cache option is built in. If you are on 1.7.x.x and prior, you will need Cm_Cache_Backend_Redis and you may consider Cm_RedisSession.