Friday, February 10, 2012

Keep products in the wishlist after adding them to cart.

Here is an interesting question I found on the Magento forum:
Leave Wishlist as it is after adding item to shopping cart?

Here is what you can do.
Override the wishlist index controller (app/code/core/Mage/Wishlist/controllers/IndexController.php) or edit it if you don't care about keeping the core clean (I recommend to keep it clean though)
and inside the method cartAction() there is this line:
$item->addToCart($cart, true);
The second parameter of the method addToCart means 'Remove from wishlist'.
You can change the second parameter to false or remove it completely - it defaults to false.

Marius.

10 comments:

  1. No simple, so great.

    Thank you.

    ReplyDelete
  2. Great work but What will be the benefits?

    ReplyDelete
    Replies
    1. I have no idea. Somebody asked it on the magentocommerce forum and I added the response here also.

      Delete
  3. When I click Add all to cart, the wishlist items is cleared. How to keep it in wishlist?Thanks

    ReplyDelete
    Replies
    1. This post should tell you exactly that. It worked for me and it seams it worked for others. I don't really know why it doesn't work for you. what have you tried for debugging?

      Delete
    2. Same Case.
      In wishlist page, I click add to the cart. The particular item add to the cart and it leave in the wishlist. However, when I click add all to the cart button, all wishlist items are removed.

      Delete
    3. Did you ever fix your "add all to the cart" problem ??
      i have the same problem :-(

      Delete
  4. Hi, I have a question about the wishlist. Do you know if is possible to remove the left navigation from the wishlist view?
    I supossed that is something in some layout because in view.phtml just load the items in the wishlist

    ReplyDelete
  5. hey Natalia. You can remove it using the layout updates. add this in one of your layout files `<wishlist_index_index><reference name="right"><action method="unsetChild"><name>NAME OF BLOCK YOU NEED REMOVED</name></action> </reference></wishlist_index_index>`

    ReplyDelete