orderLoader = $orderLoader; parent::__construct( $context, $orderAuthorization, $registry, $resultPageFactory ); } /** * {@inheritdoc} */ public function execute() { $result = $this->orderLoader->load($this->_request); if ($result instanceof \Magento\Framework\Controller\ResultInterface) { return $result; } $invoiceId = (int)$this->getRequest()->getParam('invoice_id'); if ($invoiceId) { $invoice = $this->_objectManager->create( \Magento\Sales\Api\InvoiceRepositoryInterface::class )->get($invoiceId); $order = $invoice->getOrder(); } else { $order = $this->_coreRegistry->registry('current_order'); } if ($this->orderAuthorization->canView($order)) { if (isset($invoice)) { $this->_coreRegistry->register('current_invoice', $invoice); } return $this->resultPageFactory->create()->addHandle('print'); } else { return $this->resultRedirectFactory->create()->setPath('sales/guest/form'); } } }