Redeem Now
Read More
Read now
Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-hyperlocal-marketplace-guide

    Redirect to controller from observer in magento2

    Redirect to controller from observer in magento2

    Here I am going to explain, how you redirect to a controller/action from any observer.

    Create an observer file under app/code/Company/Observer/CustomObserver.php

    In the following observer I am redirecting to the (“checkout/cart/index”) cart controller .


     

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    5 comments

  • Sn Jha
    yes it is not working. do we have another option?
  • Anu Pahuja
    its not working with ‘checkout_submit_before’. Error ‘getResponse on null’
  • ND
    How to set Message and display it on cart page?
    • Pranjali Goel (Moderator)
      you can add error/notice/success through object of Magento\Framework\Message\ManagerInterface before redirecting to cart page.
    • Pranjali Goel (Moderator)
      you can add error/notice/success message through object of Magento\Framework\Message\ManagerInterface before redirecting to cart page.
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close