Hi,
Today our client ask us why his coupon doesn't work right, he created a sales cart promotion with actions conditions where set "Not in" conditions on configurable products Skus. We found the problem
app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php
/** * Validate a condition with the checking of the child value * @param Varien_Object $object * * @return bool */ public function validate(Varien_Object $object) { /** @var Mage_Catalog_Model_Product $product */ $product = $object->getProduct(); if (!($product instanceof Mage_Catalog_Model_Product)) { $product = Mage::getModel('catalog/product')->load($object->getProductId()); } $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]); } return $valid; }
For us there is a logical error on
if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
and change in
if ($valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
because i want check on child products only if configurable check is valid.
This change resolve my client problems. But i asking why did magento develop in this way? I suppose because if i use an exclusive simple product attribute like weight, when magento validate on configurable it return false, but i'm not sure.
WHAT DO YOU THINK?
p.s.: i extended in right way the class, i reported only orignal file and code in this post, because i don't search a solution but i want open a discussion on logical problem.
Old Post - But still a bug in my eyes...
But the bug does not relate to the fact that the check is on valid / !valid on the config product, but on the plane an simple fact that the code simply takes the first child product, and not the one the customer has in the cart...