Magento 1.9 Fatal Error – Adding Configurable Product in Cart with Shopping Cart Price Rules

configurable-productfatal errormagento-1.9shopping-cart-price-rules

I have this products subselection condition in a shoppng cart price rule:

If ALL of these conditions are TRUE :
If total amount less than 16 for a subselection of items in cart matching ALL of these conditions:
Attribute Set is Heft

This works well except for configurable products. Once we add a configurable product into the cart we get this error:

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 523800 bytes) in […]/lib/Varien/Object.php on line 629

And the configurable products don't even meet the conditions! (They are another attribute set.)

Why is this happening? Can any reproduce this problem? Any help is very much appreciated.

We use Magento CE 1.9.1 and memory limit is set to 512MB. I also tried 1024MB with the same outcome.

It worked in the previous version 1.6.

I also tried to debug Magento and ended up in Mage_Sales_Model_Quote_Address at the function collectTotal. Because once I comment $model->collect($this); adding to cart works. (Of course not as expected, but the cart gets the product. Which wasn't the case before.)

Best Answer

It's a problem with method aliasing in subclasses.

tl;dr

For version CE 1.9.1.0 you can try to patch app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php at line #219 turning

$valid = $children && $this->validate($children[0]);

into

$valid = $children && self::validate($children[0]);

For other versions, find the above line inside the validate method.

Explanation

Mage_SalesRule_Model_Rule_Condition_Product_Subselect::validate() overrides the Mage_SalesRule_Model_Rule_Condition_Product_Combine::validate() and calls the parent implementation along the way. Too bad the latter eventually tries to call itself when met with rule validation on configurable products, but ends up calling the overriden implementation instead, so an infinite loop is started.

Warning

The quick fix proposed is consistent with the core SalesRule models but might break more complex class hyerarchies introduced by third party modules.

Related Topic