getRequest()->getParam('order_id'); try { $order = $this->orders->get($orderId); if ((int)$order->getCustomerId() !== (int)$this->session->getCustomerId()) { throw new \Magento\Framework\Exception\LocalizedException(__('The requested order is not available.')); } $this->getRequest()->setParam('order_increment_id', (string)$order->getIncrementId()); $thread = $this->conversations->getOrderThreadForCustomer($orderId, (int)$this->session->getCustomerId()); if ($thread) { $this->conversations->markCustomerRead((int)$thread['thread_id'], (int)$this->session->getCustomerId()); } $page = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $page->getConfig()->getTitle()->set(__('Order Messages #%1', $order->getIncrementId())); return $page; } catch (\Throwable $exception) { $this->messageManager->addErrorMessage(__('The requested order is not available.')); /** @var Redirect $redirect */ $redirect = $this->resultRedirectFactory->create(); return $redirect->setPath('sales/order/history'); } } }