orderLoader = $orderLoader; $this->creditmemoRepository = $creditmemoRepository; parent::__construct( $context, $orderAuthorization, $registry, $resultPageFactory, $creditmemoRepository ); } /** * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $result = $this->orderLoader->load($this->_request); if ($result instanceof \Magento\Framework\Controller\ResultInterface) { return $result; } $creditmemoId = (int)$this->getRequest()->getParam('creditmemo_id'); if ($creditmemoId) { $creditmemo = $this->creditmemoRepository->get($creditmemoId); $order = $creditmemo->getOrder(); } else { $order = $this->_coreRegistry->registry('current_order'); } if ($this->orderAuthorization->canView($order)) { if (isset($creditmemo)) { $this->_coreRegistry->register('current_creditmemo', $creditmemo); } return $this->resultPageFactory->create()->addHandle('print'); } else { return $this->resultRedirectFactory->create()->setPath('sales/guest/form'); } } }