Reputation: 443
I can able to remove all items in wishlist, but how do i remove individual items from wishlist
The following is the code, to remove all items in wishlist:
public function removeWishList($customer_id,$product_id)
{
$itemCollection = Mage::getModel('wishlist/item')->getCollection()
->addCustomerIdFilter($customer_id);
foreach($itemCollection as $item) {
$item->delete();
//Mage::getModel('wishlist/item')->load($product_id)->delete();
}
}
Upvotes: 0
Views: 4693
Reputation: 5211
$customerId = 1; // Replace with the customer id you are targetting
$itemCollection = Mage::getModel('wishlist/item')->getCollection()
->addCustomerIdFilter($customerId);
foreach($itemCollection as $item) {
$item->delete();
}
Upvotes: 0
Reputation: 591
Hi use this code to remove a product having productid $productId of a customer having customerid $customerId.
**$itemCollection = Mage::getModel('wishlist/item')->getCollection()
->addCustomerIdFilter($customerId);
foreach($itemCollection as $item) {
if($item->getProduct()->getId() == $productId){
$item->delete();
}
}**
Upvotes: 1
Reputation: 121
This is the standard method for removing items from a wishlist in Magento:
Mage::getModel('wishlist/item')->load($id)->delete();
Upvotes: 0