Magento utility: add multiple products to cart from catalog page

Magento utility: add multiple simple/configurable products to cart from catalog page

In the endless struggle to make our Magento stores more user-friendly, often we want to enable the customers to add multiple products in the catalog view page directly into shopping cart. This is a very convenient feature for wholesale websites, since the customer does not have to go through every single product detail page.

(This is a developer’s guide.)

We are shooting for a clean and direct fix, which I classify as a Magento utility.

The first step is to modify the /catalog/category/view.phtml, for each product in the product list, insert a form:

[codesyntax lang=”php”]

<form action="<?php echo $this->getBaseUrl() ?>utility/expressCart/add" method="post" >
    <input type="hidden" name="addToCartProductId" value="<?php echo $product->getId() ?>" />
    <p><?php echo $inputString ?></p>
    <p><input type="submit" value="<?php echo $this->__('Add to Cart') ?>"></p>