When I add the product to the cart at the wishlist page, the product automatically removed from the wishlist and the product was no longer in the wishlist page. Is there a way to keep the product at a wishlist after adding the product to the cart?
2 Answers
Currently, I cannot find the best solution for this case. My idea is to disable wishlist event (and then we can create our custom event):
<event name="checkout_cart_add_product_complete">
<observer name="wishlist" disabled="true"/>
</event>
-
-
@IdhamChoudry magento.stackexchange.com/a/130084/33057 Commented Nov 22, 2017 at 10:19
-
-
-
Here are solution which can be solved your problem:
Note: Please Override below functions which i mentioned because of best practices :)
vendor/magento/module-checkout/Controller/Cart/Add.php
public function execute()
{
/** Comment this event */
/*$this->_eventManager->dispatch(
'checkout_cart_add_product_complete',
['product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse()]
);*/
}
vendor/magento/module-wishlist/Controller/Index/Cart.php
/** Make this change */
$item->addToCart($this->cart, true);
To
$item->addToCart($this->cart, false);
Hope this can be helpful.
Happy coding :)
Thanks