In Magento, I want to remove or delete the wishlist items of a currently logged in user. Presently I am selecting the wishlist items by enabling the check boxes, and then delete them by using Mage::getModel('wishlist/item')->load($id)->delete(). The code snippet I have used is pasted below. When I click the submit button, items get deleted but the effect is only visible when I refresh the page again. The problem is I need to forcibly refresh the page so to see the items deleted. Can anybody suggest me any suitable solution. That will be appreciated.
Note: When check box is selected, wishlist-item id is assigned to its value field as:
value= $item->getWishlistItemId()
After form submission, following code executes
if(isset($_POST['wishlist'])) // wishlist is name of check box.
{
$checkboxes = $_POST['wishlist'];
foreach ($checkboxes as $id):
$bulk = $_COOKIE["bulkaction"];
if($bulk == "Remove"):
Mage::getModel('wishlist/item')->load($id)->delete(); // $id contains the wishlist item id.
$url = $this->getBaseUrl().'wishlist';
header("refresh:0.0000000000001;", $url);
endif;
endforeach;
}