I'm trying to create a link to remove an item from the wishlist if it's there. The URL is returning /wishlist/index/remove instead of the correct URL which from what I've seen online should be /wishlist/index/remove/item/[ID]. Trying that URL manually doesn't work. This is my way of getting the remove URL:
$_wishlistRemoveUrl = $this->helper('wishlist')->getRemoveUrl($_product);
Best Answer
First, an overview of how wishlists work:
wishlist_item_id
product_id
For this reason you can't just pass in a product ID to the remove URL because it's actually referencing the product's
wishlist_item_id
.This explains why you are getting a blank url ("/wishlist/index/remove"), because when you pass in the product it doesn't have the required
wishlist_item_id
, you have to retrieve this in a different way.To get around this, there is a method in
Mage_Wishlist_Model_Item
you can use to get a wishlist item by product ID:Or the shorter way:
This code has been tested in blocks of type
Mage_Catalog_Block_Product_List
andMage_Catalog_Block_Product_View