Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 14 characters in body
Source Link
Hitesh Balpande
  • 1.9k
  • 2
  • 27
  • 72

i want to redirect from observer to the default magento product url from observer.

public function __construct(
            \Magento\Framework\App\ResponseFactory $responseFactory
        ) {
        
              $this->_responseFactory = $responseFactory;
        }
        
        public function execute(Observer $observer) {
            
                $productUrl = $currentProduct->getProductUrl(); 
                //$RedirectUrl= $this->_url->getUrl('chennaievent\index\index');
                return $this->_responseFactory->create()->setRedirect($productUrl)->sendResponse();
                
            }
            
             
        }
 

i want to redirect from observer to the default magento product url.

public function __construct(
            \Magento\Framework\App\ResponseFactory $responseFactory
        ) {
        
              $this->_responseFactory = $responseFactory;
        }
        
        public function execute(Observer $observer) {
            
                $productUrl = $currentProduct->getProductUrl(); 
                //$RedirectUrl= $this->_url->getUrl('chennaievent\index\index');
                return $this->_responseFactory->create()->setRedirect($productUrl)->sendResponse();
                
            }
            
             
        }
 

i want to redirect from observer to the default magento product url from observer.

public function __construct(
            \Magento\Framework\App\ResponseFactory $responseFactory
        ) {
        
              $this->_responseFactory = $responseFactory;
        }
        
        public function execute(Observer $observer) {
            
                $productUrl = $currentProduct->getProductUrl(); 
                //$RedirectUrl= $this->_url->getUrl('chennaievent\index\index');
                return $this->_responseFactory->create()->setRedirect($productUrl)->sendResponse();
                
            }
            
             
        }
 
Source Link
Hitesh Balpande
  • 1.9k
  • 2
  • 27
  • 72

redirect to the product url from observer or controller magento 2

i want to redirect from observer to the default magento product url.

public function __construct(
            \Magento\Framework\App\ResponseFactory $responseFactory
        ) {
        
              $this->_responseFactory = $responseFactory;
        }
        
        public function execute(Observer $observer) {
            
                $productUrl = $currentProduct->getProductUrl(); 
                //$RedirectUrl= $this->_url->getUrl('chennaievent\index\index');
                return $this->_responseFactory->create()->setRedirect($productUrl)->sendResponse();
                
            }
            
             
        }