0

When clicking on the add to compare button, I want to remain on the same page & perform the add function without redirecting to the homepage - is this possible?

1
  • do you mean an ajax request?
    – phanvugiap
    Commented Jan 31, 2016 at 7:47

1 Answer 1

0

Mage_Catalog_Product_CompareController::addAction(); This call _redirectReferer() which gives redirection url to home page.

You can change this line with $this->_redirectUrl($product->getProductUrl());

OR

You can add referer_url to catalog/product_compare/add request. Mage_Catalog_Helper_Product_Compare::_getUrlParams

protected function _getUrlParams($product)
{
    return array(
        'product' => $product->getId(),
        Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl(),
        Mage_Core_Controller_Varien_Action::Mage_Core_Controller_Varien_Action => $product->getProductUrl(),
    );
}

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.