1

Ive got an issue where grouped products are not being recognized as the same thing as the downloadable product being added to the cart which makes different cart items instead of just increasing the quantity on the last cart item.

So just to explain that a bit more:

  • Grouped Product (sku: dog-stuff)
    • Downloadable Product linked to group product (sku: dog-bone)

I then programmatically add dog-bone to the cart..

My Cart shows:

  • dog-bone from grouped product
  • dog-bone from downloadable product

Hopefully that makes sense. Im trying to get them to group as the same cart item with a quantity of 2 instead of seperate items..

Here is my code to add product to cart..

    $sku = isset($_POST['sku']) ? $_POST['sku']:null;
    if(is_null($sku)){
        echo json_encode(false);
        exit;
    }
    $storeId = Mage::app()->getStore()->getId();
    $product = Mage::getModel('catalog/product')->load(Mage::getModel('catalog/product')->getIdBySku($sku))->setStoreId($storeId);
    $qty = 1;
    $quote = Mage::getSingleton('checkout/session')->getQuote();
    $item = $quote->addProduct($product, $qty);
    $quote->save();
1

This does the trick..

            $storeId = Mage::app()->getStore()->getId();
            $parentId = Mage::getModel('catalog/product')->getIdBySku($parentSku);
            $childId = Mage::getModel('catalog/product')->getIdBySku($childSku);
            $superGroup = array($childId => 1); //1 is qty
            $params = array('super_group' => $superGroup);


            $product = Mage::getModel('catalog/product')->load($parentId)->setStoreId($storeId);
            $cart = Mage::getModel('checkout/cart');
            $cart->addProduct($product, $qty)->save();
            Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
  • I have looked at this and you are setting all the super group and params above but then when it comes to adding them to the cart you dont make use of them. Therefore how can this code be adding the grouped product to the cart? – Phil Cook Aug 10 '15 at 17:01

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.