I've just upgraded from to the latest I've noticed an issue on product list pages, where the Add to Cart button now doesn't actually add the product to the cart - it simply takes you to the product detail page.

This is because in the onclick event the query string (options=cart) is missing. I have tracked this down and it seems to be as a result of some changes to Mage_Catalog_Model_Product_Url->getUrl(), whereby a product's URL is generated once and subsequently is retrieved from a stored version. This is an issue because query parameters passed through to that method have no effect!

Here's the onclick event:

onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"

It seems to be identical to the base theme's markup.

Am I missing something or is this a bug? And what would be the best way of remedying it?

3 Answers 3


if the product is configurable product or you set custom option on the product than it redirect to the product view page. you check this things.

  • It redirects to this page for all products. For configurable products I expect to see a warning message telling me to choose options, but this doesn't appear (because the query string is not appended to the URL).
    – piemanji
    Commented Sep 23, 2016 at 12:53

getAddToCartUrl() is method of this Mage_Catalog_Block_Product_Abstract class. and this class extend by only Mage_Catalog_Block_Product so you can not access this method on your category page.

this method contains below code

public function getAddToCartUrl($product, $additional = array())
    if (!$product->getTypeInstance(true)->hasRequiredOptions($product)) {
        return $this->helper('checkout/cart')->getAddUrl($product, $additional);
    $additional = array_merge(
        array(Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey())
    if (!isset($additional['_escape'])) {
        $additional['_escape'] = true;
    if (!isset($additional['_query'])) {
        $additional['_query'] = array();
    $additional['_query']['options'] = 'cart';
    return $this->getProductUrl($product, $additional);

I am not sure but if you want to use this function at category page you can use by following

<?php echo $this->getLayout()->createBlock('catalog/product')->setProduct($product)->getAddToCartUrl($product)->toHtml() ?>

I am not sure you can use above code directly in category page as this method is part of Abstract class

  • Thanks Murutuza, I'm not sure this is the problem though, since the method in question follows the base theme and does function correctly if it is first call to get a product URL. I did find a solution though, see my answer.
    – piemanji
    Commented Sep 26, 2016 at 7:42

The solution ended up being replacing

<?php echo $this->getAddToCartUrl($_product) ?>


<?php echo Mage::helper('checkout/cart')->getAddUrl($_product) ?>

- however it isn't implemented this way in the standard template files, so still not sure whether there's an issue elsewhere in my project or it's just a bug.

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.