1

I'm creating an Ajax Handler where one of the methods is removing an item from the wishlist.

I know how to add a product to the wishlist:

$wishlist = Mage::getSingleton('wishlist/wishlist')->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer());

if ($wishlist->addNewItem($product)) {
  $wishlist->save();
  $result['result']=true;
  $result['count']=$wishlist->getItemsCount();
}

I just can't find the functionality relating to removing the item from the wishlist.

Any help appreciated!

2 Answers 2

2
$product_id = "ur id";
$customer_id = Mage::getSingleton('customer/session')->getCustomer()->getId();
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer_id);
$wishListItemCollection = $wishList->getItemCollection();
foreach ($wishListItemCollection as $item) {
    $w_product_id = $item->getProductId();
    if (in_array($w_product_id, $product_id)) {
        $item->delete();
    }
}
0

Try this:

$item = Mage::getModel('wishlist/item');
$item->loadWithOptions($itemId); // You wishlist item id
$item->delete();

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.