0

I need to write a plugin for denying visitor to add to wish list and add to compare. But i cannot find which model and function i should refer to. I have implemented it successfully to disabling add to cart.

Following is my implementation sample for intercepting add product to cart.

Note: I do not wish to remove the block from user interface.

What type name and function should i refer to for:
1) Add to wish list
2) Add to compare
3) Send Email

For add to cart

<type name="Magento\Checkout\Model\Cart">
        <plugin name="interceptAddingProductToCart"
                type="Vendor\Module\Plugin\Cart"
                sortOrder="10"
                disabled="false"/>
</type>

Plugin Function

public function beforeAddProduct($subject, $productInfo, $requestInfo = null)
    {
        // logic here
    }
  • You can directly disabled wishlist from the backend. Store >> Configuration >> advanced select disable for Magento_Wishlist module. – Nits Jan 25 '18 at 4:56
1

You can refer to following files for Add to wishlist and Add to compare actions.

Add to wishlist action: Magento\Wishlist\Controller\Index\Add.php

Add to compare action: Magento\Catalog\Controller\Product\Compare\Add.php

  • In Magento2 Magento\Wishlist\Controller\Index\Add is overriden by another core module MultipleWishlist module Magento\MultipleWishlist\Controller\Index\Add so if you want to override the wishlist add controller then you should override the MultipleWishlist add controller. – Birjitsinh Zala Jan 25 '18 at 5:26

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.