0

When I am on the category list of products, and I hit "Add to Cart" on simple products, I get redirected to the cart with the product added to the cart.

However, when I add a Bundled product, even if the bundle has no configurable options, I always get redirected to the product page, where I have to click on "Add to Cart" again.

Is there a way to "fix" this so if I click "Add to Cart" on a bundled product from the category list view, it gets added to the cart immediately?

1 Answer 1

0

It appears that the "Add to Cart" button on the category list page is governed by this functionality in Mage_Catalog_Block_Product_Abstract, as shown here. As the logic goes, if there are any required options in the product, "Add to Cart" is set to the product URL, not an "Add to Cart" URL.

The solution is to replace this block function with your own, that always adds the product to the cart.

// Always add product to cart.
public function getAddToCartUrl($product, $additional = array()) {
    return $this->helper('checkout/cart')->getAddUrl($product, $additional);
}

More precisely, you need to create a block that extends Mage_Catalog_Block_Product_List, and in your config.xml you need to rewrite the product_list block inside the catalog module:

<global>
    <blocks>
        <catalog>
            <rewrite>
                <product_list>Foo_Bar_Block_Product_List</product_list>
            </rewrite>
        </catalog>
    </blocks>
</global>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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