/** * Redirects tracking popup to specific URL * @param \Magento\Framework\Event\Observer $observer * * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $shippingInfoModel = $this->_shippingInfoFactory->create()->loadByHash($this->_request->getParam('hash')); if ($url = $this->shipmentHelper->getTrackingUrlByShippingInfo($shippingInfoModel)) { $controller = $observer->getControllerAction(); $controller->getResponse()->setRedirect($url); $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true); } return $observer; }
/** * Popup action * Shows tracking info if it's present, otherwise redirects to 404 * * @return void * @throws NotFoundException */ public function execute() { $shippingInfoModel = $this->_shippingInfoFactory->create()->loadByHash($this->getRequest()->getParam('hash')); $this->_coreRegistry->register('current_shipping_info', $shippingInfoModel); if (count($shippingInfoModel->getTrackingInfo()) == 0) { throw new NotFoundException(); } $this->_view->loadLayout(); $this->_view->renderLayout(); }