1

i want to create a empty wishlist button in wishlist page, so that when user click the button all the items from the wishlist are removed. how can i do that please help.

  • you want to remove wishlist items – Rakesh Donga Mar 26 at 6:59
  • yes, i want to remove all items at once. – abhishek kalotra Mar 26 at 8:23
1

Example of adding button in wishlist, change button as per your need

<wishlist_index_index>
    <reference name="customer.wishlist.buttons">
        <block type=“wedding/customer_wishlist_button" name="customer.wishlist.button.gifts" template=“wedding/button/gifts.phtml" />
    </reference>
</wishlist_index_index>

You need to add separate controller action on this button click

Code of empty Wishlist

if (Mage::getSingleton('customer/session')->isLoggedIn()) {
 $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();

$itemCollection = Mage::getModel('wishlist/item')->getCollection()
                    ->addCustomerIdFilter($customerId);
    foreach($itemCollection as $item) {
            $item->delete();
    }
}

I hope this will help

  • can you give me the location for this controller – abhishek kalotra Mar 26 at 11:13
  • 1
    @abhishek you need to make controller in your custom module path would be some thing like app/code/local/Packagename/Yourmodulename/ in controller folder if you still don't get it please check any tutorial how to add controller in custom module it is very basic. After adding controller you have to hit controller action through url either by setting form action or button on click. If my answer is helpful please mark it correct. Keep coding :) thanks – Muhammad Hasham Mar 28 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.