I've been playing around with the Shopping Cart Price Rules for Magento Enterprise and have stumbled across a problem.

I was trying to create a simple rule such that you would get a £10 discount if you buy any 3 items from a defined category, and have spent more than £15. See my configuration below.

Rule Information Conditions Actions

In my basket I have 3 items from the category with id 5, and 1 item from the category with id 3.

When I enable this rule and view my basket, I receive the fatal error. Here's a section of the stack trace. As you can see I've already bumped up the xdebug.max_nesting_level to horrifying levels.

Fatal error: Maximum function nesting level of '18000' reached, aborting! in /dev/builds/1_14_1_0/lib/Varien/Object.php on line 344 Call Stack:
0.0003 348680 1. {main}() /dev/builds/1_14_1_0/index.php:0
0.0020 694956 2.Mage::run() /dev/builds/1_14_1_0/index.php:89
0.0068 1819640 3.Mage_Core_Model_App->run() /dev/builds/1_14_1_0/app/Mage.php:684
0.0509 9129168 4.Mage_Core_Controller_Varien_Front->dispatch() /dev/builds/1_14_1_0/app/code/core/Mage/Core/Model/App.php:354
0.0626 11074424 5. Mage_Core_Controller_Varien_Router_Standard->match() /dev/builds/1_14_1_0/app/code/core/Mage/Core/Controller/Varien/Front.php:172
0.0658 11765288 6. Mage_Core_Controller_Varien_Action->dispatch() /dev/builds/1_14_1_0/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250
0.1314 16963044 7. Mage_Checkout_CartController->indexAction() /dev/builds/1_14_1_0/app/code/core/Mage/Core/Controller/Varien/Action.php:418
0.3065 27313592 8. Mage_Checkout_Model_Cart->save() /dev/builds/1_14_1_0/app/code/core/Mage/Checkout/controllers/CartController.php:144
0.3195 28006864 9. Mage_Sales_Model_Quote->collectTotals() /dev/builds/1_14_1_0/app/code/core/Mage/Checkout/Model/Cart.php:458
0.3827 32507432 10. Mage_Sales_Model_Quote_Address->collectTotals() /dev/builds/1_14_1_0/app/code/core/Mage/Sales/Model/Quote.php:1331
0.6151 37466752 11. Mage_SalesRule_Model_Quote_Freeshipping->collect() /dev/builds/1_14_1_0/app/code/core/Mage/Sales/Model/Quote/Address.php:1013
0.6245 37839108 12. Mage_SalesRule_Model_Validator->processFreeShipping() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php:74
0.6247 37839784 13. Mage_SalesRule_Model_Validator->_canProcessRule() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Validator.php:249
0.6282 37960924 14. Mage_Rule_Model_Abstract->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Validator.php:223
0.6418 38895940 15. Mage_Rule_Model_Condition_Combine->validate() /dev/builds/1_14_1_0/app/code/core/Mage/Rule/Model/Abstract.php:353
0.6420 38896372 16. Mage_SalesRule_Model_Rule_Condition_Product_Subselect->validate() /dev/builds/1_14_1_0/app/code/core/Mage/Rule/Model/Condition/Combine.php:307
0.6421 38896772 17. Mage_SalesRule_Model_Rule_Condition_Product_Combine->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php:117
0.6428 38898084 18. Mage_SalesRule_Model_Rule_Condition_Product_Subselect->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php:219
0.6429 38898484 19. Mage_SalesRule_Model_Rule_Condition_Product_Combine->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php:117
0.6433 38898572 20. Mage_SalesRule_Model_Rule_Condition_Product_Subselect->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php:219
0.6434 38898972 21. Mage_SalesRule_Model_Rule_Condition_Product_Combine->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php:117
0.6439 38899060 22. Mage_SalesRule_Model_Rule_Condition_Product_Subselect->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php:219
0.6440 38899460 23. Mage_SalesRule_Model_Rule_Condition_Product_Combine->validate() /dev/builds/1_14_1_0/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php:117

When I remove the If total quantity is 3 section from the Condition then Magento no longer freaks out. Could someone point me in the correct way to configure this promotion, as well as shed some light on why I'm fataling?

This is a vanilla installation of Magento, and I'm concerned that I can break the shopping cart so easily.


I am running mysql as

Server version: 5.5.41-0ubuntu0.12.04.1 (Ubuntu)

And PHP as

PHP 5.3.10-1ubuntu3.15 with Suhosin-Patch (cli) (built: Oct 29 2014 12:16:30) 
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
        with the ionCube PHP Loader v4.0.10, Copyright (c) 2002-2011, by ionCube Ltd., and
        with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Update 2

A database dump is available here, comes in at ~130kb.


  • Was created with mysql running it as root @ localhost with no password
  • Magento admin panel username is admin and the password is password1
  • You'll need to update the web/unsecure/base_url and web/secure/base_url in core_config_data to point to your install instance.

To replicate

  1. As guest, Add 1 Green Bowler to your basket
  2. Then Add 3 Green Boots to your basket
  3. Hopefully have a horrible error like I am seeing
  • I recreated your same shopping cart rules, and able to apply with no issues on a vanilla install. Which product types are you attempting to add to the cart to trigger the rule? Have you tried doing a full re-index and/or adding any debug code, particularly to github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…
    – B00MER
    Feb 24, 2015 at 2:39
  • Both products are configurable. I just ran a magerun index:reindex:all and it made no difference. I'm super busy today and tomorrow at work, but if you still fail to replicate I will be able to provide a DB dump on thursday if that's good? Feb 24, 2015 at 9:34
  • A DB dump would help, as long as its not super large. Since is the latest i'm aware of and have experienced some oddities with promo rules as well. It is possible it may be a bug.
    – B00MER
    Feb 26, 2015 at 2:22
  • Cool, I'll get that for you in a few hours. Thank you. Feb 26, 2015 at 7:37
  • Check the updates to the post. It's got a link to the DB dump and a few notes. Feb 26, 2015 at 16:01

1 Answer 1


took the change to dive into this. Installed a clean Magento Enterprise

Your rule still breaks without the first >15 rule...

It's origin is in the product subselection.

These two functions who are calling itself repeatedly.


More specific:


foreach ($object->getQuote()->getAllVisibleItems() as $item) {
    if (parent::validate($item)) { // Call parent


$valid = parent::validate($object);
if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
    $children = $object->getChildren();
    $valid = $children && $this->validate($children[0]); // call upper function, I not aware I'm really calling Product_Select::validate()

As you can see, if the product is a configurable(which in true your case for both products) call the extended function again. And so on, and on, and on, and on...

It is indeed a Magento bug because it doesn't check if it is a valid item passed to the function.

Normally the function is called with Mage_Sales_Model_Quote_Address and in the recursion with Mage_Sales_Model_Quote_Item so we can build a fix for it. Both also have a getQuote() function.

If you want to resolve it in you case it is done by adding these tree lines.


 * validate
 * @param Varien_Object $object Quote
 * @return boolean
public function validate(Varien_Object $object)
    // Check if recursion is the case, ask parent to handle
    // *** START FIX
    if ($object instanceof Mage_Sales_Model_Quote_Item) {
        return parent::validate($object);
    // *** END FIX

    if (!$this->getConditions()) {
        return false;

You could copy this file to app/code/local/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php

So my last check is to see if it also applies for Magento CE This is also the case because the parent function is implemented in the CE edition. Magento CE is not affected, it does not has the parent function! So I'm guessing Magento EE is also free from this, because the are inherent to each other.

You should create a ticket in your Magento Enterprise account and supply the information so they can make a patch for this.

  • So it is in Magento CE and up, I've missed it the last time... strange... Will file a bug at Magento's
    – Jeroen
    Mar 19, 2015 at 21:24
  • 2
    Filed a bug
    – Jeroen
    Mar 19, 2015 at 21:33

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.