Add group product in cart magento

$productModel = Mage::getModel('catalog/product');
$super_group = array();
$parentId = $params['productid'];
$qty = 1;
// $parentId =  
$parentProduct = $product_model->load($parentId);
$associatedProducts = $parent_prod->getTypeInstance()->getAssociatedProducts();
//set quantity of associate product
 foreach ($associatedProducts as $product) {
            $array[$product->getId()] = $qty;
$params['super_group'] = $array;
$product = Mage::getModel('catalog/product')->load($parentId);
//check product availability
if (!$product) {
                echo "Error";
// create cart object
 $cart = Mage::getModel('checkout/cart');
$param = array('super_group' => $super_group);
 //Add product to cart with specified parameters 
$cart->addProduct($product, $params);
//and save the cart object
//update cart

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.