Hello Magento Friends,

Hope everything is groovy and fab at your end. Today I will help you to solve How to Prevent Adding Duplicate Product to Wishlist in Magento 2.

In default Magento 2, if the customer adds any product to the wishlist it also allows repetitive products to be added to the wishlist. The Magento 2 store admin can still delete the duplicate products in the wishlist and also prevent adding the same. The customers can easily manage their wishlist by preventing duplicate items to be added.

So, let’s get started with the steps on How to Prevent Adding Duplicate Product to Wishlist in Magento 2.

Steps to Prevent Adding Duplicate Product to Wishlist in Magento 2:

Step 1: Firstly, go to the below path

app\code\Vendor\Extension\etc\events.xml

Now, add the below code

Step 2: Next, move to the below path

app\code\Vendor\Extension\Observer\WishlistItemBeforeAdd.php

And add the code as mentioned below

Conclusion:

Hopefully, all are able to Prevent Adding Duplicate Product to Wishlist in Magento 2. For any difficulty, while executing the code, do let me know in the comment sections below. Ensure you share the article with your Magento colleagues and on your social media platforms.

Stay in touch for future updates! 

Happy Coding!

Click to rate this post!
[Total: 8 Average: 5]