I change in code follow this http://www.magentocommerce.com/boards/viewthread/197868/ to keep items in wishlist when user add item to cart. But If user add all to cart instead of each item. All product will be remove from wishlist. I want to keep it in wishlist. Have any know how to fix it? I try to open app\code\core\Mage\Wishlist\Controller\Abstract.php and comment out lines $item->delete(); But nothing better. I'd appriciate your helping.
3 Answers
Try this,
Step 1:
While adding allitems from wishlist to cart, there is no way to rewrite abstract file. so copy the file from
app\code\core\Mage\Wishlist\Controller\Abstract.php
to
app\code\local\Mage\Wishlist\Controller\Abstract.php
Then find inside Abstract.php
if ($item->addToCart($cart, $isOwner)) {
$addedItems[] = $item->getProduct();
}
set $isOwner
to false
.Update the code as
$isOwner = false;
if ($item->addToCart($cart, $isOwner)) {
$addedItems[] = $item->getProduct();
}
Step 2:
While adding individual items from wishlist to cart. Follow the below steps
Rewrite the Mage_Wishlist_IndexController
to local codepool
Then find the code in the rewrited controller file
if ($item->addToCart($cart, $isOwner)) {
$addedItems[] = $item->getProduct();
}
Update the code as
$isOwner = false;
if ($item->addToCart($cart, $isOwner)) {
$addedItems[] = $item->getProduct();
}
Now wislist items will retain even after add to cart.
Refer this link
Tought about that too, but figured out that the deletion happens on line 108 in Mage_wishlist_Controller_Abstract
// Add to cart
if ($item->addToCart($cart, $isOwner)) {
$addedItems[] = $item->
}
In your Wishlist the $isOwner is set to true and that's the reason why your items get removed. set $isOwner is set to false to stop the items get removed
The way I solved this instead of overwriting or editing a abstract core file like some comments suggest I instead did a rewrite of the Wishlist controller:
Mage/Wishlist/controllers/IndexController.php
If you look in the cartAction
function on you will find the following line $item->addToCart($cart, true);
. The second parameter being sent here decides if the item should be deleted from the wishlist or not. If you in your rewritten controller set this to false the items will persist in the wishlist even though you add them to your cart.