I am using the following to throw the exception it is working for me to add to cart prevent.

use Magento\Framework\Exception\StateException;
use Magento\Framework\Exception\LocalizedException;

But when I am trying to add to cart from compare page. page redirect to following.


How to solve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.