Skip to content

Instantly share code, notes, and snippets.

@mzeis
Last active December 31, 2015 19:49
Show Gist options
  • Save mzeis/8036184 to your computer and use it in GitHub Desktop.
Save mzeis/8036184 to your computer and use it in GitHub Desktop.
Reduces the memory usage in the checkout process when using Ebizmarkets_MageMonkey (will be included in future releases).

Open app/code/community/Ebizmarts/MageMonkey/Helper/Data.php and search for

$last_order = Mage::getResourceModel('sales/order_collection')
    ->addFieldToFilter('customer_email', $customer->getEmail())
    ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
    ->setOrder('created_at', 'desc')
    ->getFirstItem(); 

and replace it with

$last_order = Mage::getResourceModel('sales/order_collection')
    ->addFieldToFilter('customer_email', $customer->getEmail())
    ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
    ->setOrder('created_at', 'desc')
    ->setPageSize(1)
    ->getFirstItem(); 

In our case the memory footprint at this code line was reduced from > 1 GB to about 17 MB.

See Conquer the 5 Most Common Magento Coding Issues to Optimize Your Site for Performance, page 14 for the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment