how to change url of "add to wishlist" button in magento

how to change url of "add to wishlist" button in magento

October 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
how to change url of "add to wishlist" button in magento

Changing the URL of “Add to Wishlist” Button in Magento

Are you new to Magento and struggling to locate where to modify the URL for your website’s “Add to Wishlist” button? You’re not alone! This is a common challenge faced by many Magento beginners.

Understanding the Problem

When you install Magento, it comes with default URLs for various features, including the wishlist functionality. The problem arises when you want to customize these URLs to better suit your website’s structure or SEO needs.

Locating the Wishlist Controller

The first step is to understand where the “Add to Wishlist” URL is generated. In Magento, this action is handled by a controller called wishlist. You can find it under the following path:

app/code/core/Mage/Wishlist/controllers/IndexController.php

Modifying the URL in the IndexController

To change the URL, you’ll need to modify the code in the add action of this controller. This is where the wishlist item is saved and the response is generated.

Here’s an example of how you might change the default URL:

public function addAction() {
    // Your existing code...

    $result = array(
        'item_id' => $itemId,
        'url' => Mage::helper('wishlist')->getAddUrl($product, $params),
    );

    if ($this->getRequest()->isAjax()) {
        return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
    }

    $this->_redirect('wishlist/index');
}

In the above example, we’ve added a new key url to store the modified URL. We’ll use Magento’s built-in helper function Mage::helper('wishlist')->getAddUrl() to generate the new URL.

The key change is in the $this->_redirect('wishlist/index'); line. This is where you can specify your custom URL using the Mage_Core_Controller_Varien_Action::redirect() method.

For instance, if you want to redirect to a custom wishlist page after adding an item:

$this->_redirect('mycustommodule/mycustomcontroller');

Important Considerations

Remember that changing URLs can have implications for SEO and user experience. Always test your changes thoroughly before deploying them live on your production site.

Also, consider using Magento’s built-in URL rewrite functionality if you’re looking to change the base URL of your store or a specific route. This ensures that your old links will continue to work even after the change.

Conclusion

Changing the “Add to Wishlist” button URL in Magento is possible but requires some knowledge of the core codebase and controller actions. By following this guide, you should be able to make the necessary modifications.

Remember, Magento’s architecture allows for a high degree of customization, but it also means that changing core files can have unintended consequences if not handled carefully.

If you’re looking for more advanced Magento development help or need assistance with other aspects of your e-commerce store, consider reaching out to Laravel Company. Our team of experienced developers specializes in creating robust and secure Magento solutions tailored to your business needs.

Click here to learn more about our Magento services and how we can help you unlock the full potential of this powerful e-commerce platform.

Catalog SEO Errors JavaScript

Our network