I have a website based on magento c.e 1.7, now i need a "add to cart" button on my cms page which add multiple simple products to the cart. Right now i have id of those products, there is no problem with quantity as i only need to add each product with quantity one.

Thanks in advance, Sarvagya

2 Answers 2


You can add a product via POST to checkout/cart/add/product/<id> and add more simple items via $_GET['related_products'] = array('id', 'id2', ...)


I got the solution it is:

I just used the array of product ids and applied it to the loop which takes every product and add it to the cart.

Code :

foreach($prod_array as $product_id){ /*$prod_array contains the ids of products */
        $product = Mage::getModel('catalog/product')// set the current store ID
                     // load the product object
        $session = Mage::getSingleton('core/session', array('name'=>'frontend'));
        $cart = Mage::helper('checkout/cart')->getCart();
        $cart->addProduct($product,1); /* In my case the quantity is 1 */

may be it will help someone

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.