1

we are experiencing very slow performance in "add to cart" action and the cart page. other pages are fine with apc, block cache, etc.

also, we have read online, and disabled rss module, download module, and only about 80-100 active shopping cart rules.

any help we can improve the "Add to cart" performance? thx for help.

ed

2

Of the top reading your post one thing stands out.

and only about 80-100 active shopping cart rules

That's actually quite a lot, it means that every time you change the cart Magento has to process these rules to see if they apply.

Make sure you delete or inactivate the unused rules, this should improve the speed.

Another suggestion would be to make the jump to a newer version of Magento. I wouldn't advice an upgrade from 1.4 to 1.8, from my own experience and what I've read only it'll cause a lot of issues but it might be a good investment to rebuild the shop on the latest Magento version.

2
  • You can deactivate modules that are not required, especially the Mage_Rss module is a good candidate (as already mentioned)
  • If you - for whatever reason - can not deactivate a module, you can disable observers that slow down your checkout performance. For example in the Mage_Downloadable module the Observers for sales_order_item_save_commit_after and sales_order_save_commit_after may be a candidate. Also check other observers for all cart-, cart item or salesrule related events.
  • Try to merge your active shopping cart price rules. As already mentioned, 80-100 rules is a lot. All these rules need to be checked when updating your cart. Maybe you can merge some rules together, to reduce the total number of rules

Another thing I did once: When adding a product to the cart, it is usually loaded by getModel('catalog/product')->load($productId). I replaced this by loading the product via the product collection. As far as I can remember this saved about 0.5s. You will have to rewrite the Mage_Checkout_CartController::_initProduct() for that. And also be sure to load the inventory data. You may have to do this manually by

Mage::getModel('cataloginventory/stock')->addItemsToProducts($productCollection);

Or use the require_stock_items Flag. Also also use addPriceData() on your collection. So your call looks like this:

$arrayOfProductAttributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$productCollection = Mage::getResourceModel('catalog/product_collection)
    ->addAttributeToSelect($arrayOfProductAttributes)
    ->setFlag('require_stock_items', true)
    ->addPriceData()
    ->addUrlRewrite() // maybe not required
    ->setPageSize(1,1);


$product = $productCollection->getFirstItem();

Hope that helps.

On the other hand you could use the handy tool kcachegrind in combination with xdebug for analysing slow parts of your addToCart action (xdebug will create the cache grinds, kcachegrind can analyse them). It is quite surprising, that for example Varien_Object::getData() calls (used by magic getters/setters) can remarkably slow down some processes!

2
  • as i said, already disabled rss and downloadable observers. and already using block cache. wonder if there is actual coding optimization that can be made.... – Angel Wong Oct 14 '13 at 13:46
  • I updated my answer - now I'm out of ideas :( – Jan Wy Oct 16 '13 at 10:00

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.