conversations->getThreadsForAdmin(); } public function getSelectedThread(): ?array { $threadId = (int)$this->getRequest()->getParam('thread_id'); if ($threadId) { return $this->conversations->getThreadForAdmin($threadId); } $orderId = (int)$this->getRequest()->getParam('order_id'); return $orderId ? $this->conversations->getOrderThreadForAdmin($orderId) : null; } public function getMessages(?array $thread): array { return $thread ? $this->conversations->getMessages((int)$thread['thread_id']) : []; } public function getOrder(): ?\Magento\Sales\Api\Data\OrderInterface { $orderId = (int)$this->getRequest()->getParam('order_id'); if (!$orderId) { return null; } try { return $this->orders->get($orderId); } catch (\Throwable) { return null; } } }