I'm updating an old Magento instance from to (I know there is the v.

I'm also using the Ultimo theme, but i tested the bug also with the standard RWD theme that comes with Magento 1.9.

The issue is about the add to compare button: it doesn't work. It only redirects me to the same page but it doesn't add the product to compare list.

I find out that the problem is in the addAction() function in CompareController.php

There is

public function addAction()
    if (!$this->_validateFormKey()) {

And $this->_validateFormKey() return FALSE so nothing is done.

Just for information, my add to compare link are looking like the following


At the moment, my solution is to comment the IF.

Somebody knows how to solve this problem?

Into the template file addto.phtml the code is the following:

    $_compareUrl = $this->helper('catalog/product_compare')->getAddUrl($_product);
<?php if($_compareUrl) : ?>

        <a class="link-compare feature feature-icon-hover first" href="<?php echo $_compareUrl ?>" title="<?php echo $this->__('Add to Compare') ?>">
            <span class="ic ic-compare ib icon-color-productview"></span>
            <span class="label"><?php echo $this->__('Add to Compare') ?></span>

<?php endif; ?>
  • I suggest you post your edit as an answer and accept it, since it seems to have solved your issue. Commented Nov 3, 2015 at 15:22

2 Answers 2


You will need to change compare URL in your phtml

    $_compareUrl = $this->helper('catalog/product_compare')->getAddUrl($_product);

This code will give you the right compare URL for your product.

If this will not work show your phtml code which have compare link.

  • Thanks for the answer, but my code is already this. Commented Nov 3, 2015 at 11:42
  • actually compare url should be like catalog/product_compare/add/product/2480/uenc/aHR0cDovL2NjY2Rlc2t0b3AuY29tL3RlYW0vYWtoaWxlc2gvbWFnZTE5L2xhZmF5ZXR0ZS1jb252ZXJ0aWJsZS1kcmVzcy5odG1s/form_key/jHkteueHaz064EL8/ and in your case it is not adding this form_key in URL. try to debug in class Mage_Catalog_Helper_Product_Compare Commented Nov 3, 2015 at 12:22
  • Found!!! Thanks for the advise... I have an overload in local/ for the Mage_Catalog_Helper_Product_Compare class. Commented Nov 3, 2015 at 14:38

I have an old overload in the local folder for the Mage_Catalog_Helper_Product_Compare Class, so it has not the new FORM_KEY feature in the function getAddUrl().

Thanks to @Akhilesh Patel

  • great!! you can accept my answer as well if that help you :) Commented Nov 4, 2015 at 5:40

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.