Пример #1
0
 /**
  * Print Invoice Action
  *
  * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     $invoiceId = (int) $this->getRequest()->getParam('invoice_id');
     if ($invoiceId) {
         $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId);
         $order = $invoice->getOrder();
     } else {
         $orderId = (int) $this->getRequest()->getParam('order_id');
         $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId);
     }
     if ($this->orderAuthorization->canView($order)) {
         $this->_coreRegistry->register('current_order', $order);
         if (isset($invoice)) {
             $this->_coreRegistry->register('current_invoice', $invoice);
         }
         /** @var \Magento\Framework\View\Result\Page $resultPage */
         $resultPage = $this->resultPageFactory->create();
         $resultPage->addHandle('print');
         return $resultPage;
     } else {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         if ($this->_objectManager->get('Magento\\Customer\\Model\\Session')->isLoggedIn()) {
             $resultRedirect->setPath('*/*/history');
         } else {
             $resultRedirect->setPath('sales/guest/form');
         }
         return $resultRedirect;
     }
 }
Пример #2
0
 /**
  * Print Invoice Action
  *
  * @return void
  */
 public function execute()
 {
     $invoiceId = (int) $this->getRequest()->getParam('invoice_id');
     if ($invoiceId) {
         $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId);
         $order = $invoice->getOrder();
     } else {
         $orderId = (int) $this->getRequest()->getParam('order_id');
         $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId);
     }
     if ($this->orderAuthorization->canView($order)) {
         $this->_coreRegistry->register('current_order', $order);
         if (isset($invoice)) {
             $this->_coreRegistry->register('current_invoice', $invoice);
         }
         $this->_view->loadLayout('print');
         $this->_view->renderLayout();
     } else {
         if ($this->_objectManager->get('Magento\\Customer\\Model\\Session')->isLoggedIn()) {
             $this->_redirect('*/*/history');
         } else {
             $this->_redirect('sales/guest/form');
         }
     }
 }
Пример #3
0
 /**
  * @param RequestInterface $request
  * @return bool|\Magento\Framework\Controller\Result\Forward|\Magento\Framework\Controller\Result\Redirect
  */
 public function load(RequestInterface $request)
 {
     $orderId = (int) $request->getParam('order_id');
     if (!$orderId) {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->resultForwardFactory->create();
         return $resultForward->forward('noroute');
     }
     $order = $this->orderFactory->create()->load($orderId);
     if ($this->orderAuthorization->canView($order)) {
         $this->registry->register('current_order', $order);
         return true;
     }
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->redirectFactory->create();
     return $resultRedirect->setUrl($this->url->getUrl('*/*/history'));
 }
Пример #4
0
 /**
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 public function load(RequestInterface $request, ResponseInterface $response)
 {
     $orderId = (int) $request->getParam('order_id');
     if (!$orderId) {
         $request->initForward();
         $request->setActionName('noroute');
         $request->setDispatched(false);
         return false;
     }
     $order = $this->orderFactory->create()->load($orderId);
     if ($this->orderAuthorization->canView($order)) {
         $this->registry->register('current_order', $order);
         return true;
     }
     $response->setRedirect($this->url->getUrl('*/*/history'));
     return false;
 }