How to redirect from around plugin to another page with an error ?

1 Answer 1


Not tested but this might work for you. The ManagerInterface class will set the error message and response class will help in redirecting to specific url.

namespace Vendor\ModuleName\Plugin;

class MyPluginClass
    private $response;

    private $messageManager;

    public function __construct
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Framework\App\Response\Http $response
        $this->messageManager = $messageManager;
        $this->response = $response;

    public function aroundSomeMethod($subject, $proceed, $someThingForTrue){
            $this->messageManager->addErrorMessage(__('There seems to be some error'));
            $url = 'http://mystoreurl.com';
  • I will check and let u know. Thanks for the response. Commented Jan 4, 2019 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.