Add to wishlist without redirect to wishlist
-
16-10-2019 - |
Question
How to disable or redirect to same page after pushing add to wishlist button? Same way you can disable it for add to cart.
Solution
You can override the add to wishlist action in the wishlist controller and make it redirect to the referrer.
Override this method Mage_Wishlist_IndexController::addAction()
and replace this:
$this->_redirect('*', array('wishlist_id' => $wishlist->getId()));
with this:
$this->_redirectReferer()
OTHER TIPS
Actually the "addAction" in turn calls "_addItemToWishList" function, so you have to override that function in wishlist IndexController.php
Refer the below link, it shows how to override wishlist controller, also take care of the issue it has posted:
As it says replace the $this->_redirect('*', array('wishlist_id' => $wishlist->getId()));
with $this->_redirectReferer();
Also don't let any spaces between "<" and tag name in any of the magento's xml files, it breaks xml structure.
For cart you have to override cart controller with minor function name change.
Hope this helps, let me know in comments.
Override this method Mage_Wishlist_IndexController::addAction()
and replace below code:
$this->_redirect('*', array('wishlist_id' => $wishlist->getId()));
with following:
$this->_redirectUrl(Mage::helper('core')->escapeUrl($referer));