3

I have made a new Magento shopping store .I want my customers can to add multiple products at once in the shop cart, is this possible ? can anyone help me ?

0

2 Answers 2

2

You can add products to cart programmatically:

/** @var Mage_Checkout_Model_Cart $cart */
$cart = Mage::getSingleton('checkout/cart');
$productIds = array(1, 2, 3, 4);
foreach ($productIds as $productId) {
    /** @var Mage_Catalog_Model_Product $product */
    $product = Mage::getModel('catalog/product');
    $product->load($productId);
    $cart->addProduct($product);
    $cart->save();
}

and build the functionality where you need it. Or buy a module like this one.

1
class BTS_AddMultipleProducts_AddController extends Mage_Core_Controller_Front_Action {
public function indexAction() {

    $products = explode(',', $this->getRequest()->getParam('products'));
    $cart = Mage::getModel('checkout/cart'); 
    $cart->init(); /* @var $pModel Mage_Catalog_Model_Product */ 
    foreach ($products as $product_id) { 
        if ($product_id == '') { continue; } 
        $pModel = Mage::getModel('catalog/product')->load($product_id); 
        if ($pModel->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
         try {
            $cart->addProduct($pModel, array('qty' => '1')); 
          } catch (Exception $e) {
                continue; 
          } 
        } 
    } 
    $cart->save(); 
    if ($this->getRequest()->isXmlHttpRequest()) {
        exit('1'); 
    } $this->_redirect('checkout/cart'); 
}   

}

You can follow this link

http://www.danneh.org/2011/09/adding-multiple-products-cart-simultaneously-magento-part-2/

Its also help you.

1
  • 1
    It would be great if you could rephrase the most important parts and copy them over there, so your answer is still helpful when the link is dead. Jun 24, 2014 at 12:45

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