Neptune Web, Inc. logo

Improving Magento Checkout Performance with Large Number of Cart Rules

If you've had problems with performance in your Enterprise 1.8 Magento cart and checkout process, it could be due to a large number of sales cart rules.

We've found more than 25 rules will make performance completely unacceptable. The problem occurs when large # of sales cart rules, combined with the number of items in your cart. This is exacerbated when there is a large number of attributes on products.

Try removing all of your cart rules to see if this is the source of your problem.

Each cart sales rule makes a call to the product load() function which (in our dedicated environment) costs .100 (1/10) second. This function is very slow, because it has to compose the Entity-Attribute-Value (EAV) records from many tables (see details on EAV on Magento's site).

Multiply products in the cart by number of rules to estimate how slow your cart or checkout page will be.

To fix this, just override the product->load() function. Create a simple global to store previously loaded products. (Obviously, this "cache" is valid for 1 request only).

Now, calls to load() are based on the number of items in cart only. This can make a huge difference in performance - and in your users' shopping cart experience.

Here is a code sample of how your overridden Product class should look:

	public function load($id, $field=null) {
	if (isset($ECV_GLOBAL_CACHE)) {

	} else {
			$ECV_GLOBAL_CACHE = array();
	if (isset($ECV_GLOBAL_CACHE[$id])) {
					//error_log("since $id was already loaded, we return global version - cache it");
					return $ECV_GLOBAL_CACHE[$id];
	} else {
					$ECV_GLOBAL_CACHE[$id] = parent::load($id,$field);
					//error_log(" $id was NOT already loaded, call ev tables - no cache");
					return $ECV_GLOBAL_CACHE[$id];

I hope this helps you out. As always, contact us know if there is anything we can do to help support your Magento installation!


Neptune Web is a full-service Boston-area interactive web and digital marketing agency with expertise in Website Design, Web Development, Digital Marketing Strategy and Execution.

We look forward to your comments and would be most happy to address and help solve any Digital Marketing or Website Design & Development challenges you may have.

comments powered by Disqus