0

In the core wishlist indexcontroller I am replacing the configurable product with it's configured child product before i add it to the wishlist using:

    $productId = (int)$this->getRequest()->getParam('product');
    $product = Mage::getModel('catalog/product')->load($productId);
    if($product->getTypeId() == 'configurable'){
        $params = $this->getRequest()->getParams();
        $child = $product->getTypeInstance(true)->getProductByAttributes($params['super_attribute'], $product);
        $product = Mage::getModel('catalog/product')->load($child->getId());
    }

This works well to get the simple product into the wishlist. However, when I add a different configuration (color = red) to the wishlist it will replace the previous configuration(color = blue) with a new one (color = red). When I add the same configuration(color = red) again it will delete that configuration entirely leaving the wishlist empty.

Without the above alteration, the configurable item will not be replaced and the quantity will simply iterate upon addition of the same item.

Thx

4
  • Where did you add this code exactly? around line 206? My best guess is that it has to do with the buy request but I'll need more info Nov 7, 2014 at 19:04
  • @SanderMangel The only recent development I have is that this problem persists without the above change. The simple products aren't persistent in our live site if you add the item directly into our wishlist (a normal user wouldn't be able to access these products via searching / links anyway). So this is truly anomalous behavior as our indexcontroller is enterprise edition. Nov 7, 2014 at 19:49
  • The #magestackday team is on it. We'll look into it :) Nov 7, 2014 at 19:52
  • Im having this exact issue with grouped products, any ideas? Feb 1, 2018 at 12:14

1 Answer 1

4

Did some testing on a Magento 1.9 installation and figured out how to swap the products. The trick lies in the $buyRequest

$buyRequest = new Varien_Object($requestParams); // this is the original code

[...]

$productId = (int)$this->getRequest()->getParam('product');
$product = Mage::getModel('catalog/product')->load($productId);
if($product->getTypeId() == 'configurable'){
   $params = $this->getRequest()->getParams();
   $child = $product->getTypeInstance(true)->getProductByAttributes($params['super_attribute'], $product);
   $product = Mage::getModel('catalog/product')->load($child->getId());
   $buyRequest->setData('product', $child->getId());
}
3
  • 1
    Got pointed out you should probably also update the updateItemOptionsAction function Nov 7, 2014 at 20:25
  • Is this still in the indexController? In my experience, overriding controller files doesn't work so you'd be having to modify a core file. Or did you manage to find a Model to add this code to? Jul 15, 2015 at 13:07
  • No this is the controller. Overwriting the controller should work. I think Inchoo has a nice article on that Jul 15, 2015 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.