示例#1
0
    /**
     * Action for reorder
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function executeInternal()
    {
        $result = $this->orderLoader->load($this->_request);
        if ($result instanceof \Magento\Framework\Controller\ResultInterface) {
            return $result;
        }
        $order = $this->_coreRegistry->registry('current_order');
        /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        /* @var $cart \Magento\Checkout\Model\Cart */
        $cart = $this->_objectManager->get('Magento\Checkout\Model\Cart');
        $items = $order->getItemsCollection();
        foreach ($items as $item) {
            try {
                $cart->addOrderItem($item);
            } catch (\Magento\Framework\Exception\LocalizedException $e) {
                if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getUseNotice(true)) {
                    $this->messageManager->addNotice($e->getMessage());
                } else {
                    $this->messageManager->addError($e->getMessage());
                }
                return $resultRedirect->setPath('*/*/history');
            } catch (\Exception $e) {
                $this->messageManager->addException($e, __('We can\'t add this item to your shopping cart right now.'));
                return $resultRedirect->setPath('checkout/cart');
            }
        }

        $cart->save();
        return $resultRedirect->setPath('checkout/cart');
    }
示例#2
0
 /**
  * Action for reorder
  *
  * @return void
  */
 public function execute()
 {
     if (!$this->orderLoader->load($this->_request, $this->_response)) {
         return;
     }
     $order = $this->_coreRegistry->registry('current_order');
     /* @var $cart \Magento\Checkout\Model\Cart */
     $cart = $this->_objectManager->get('Magento\\Checkout\\Model\\Cart');
     $items = $order->getItemsCollection();
     foreach ($items as $item) {
         try {
             $cart->addOrderItem($item);
         } catch (\Magento\Framework\Model\Exception $e) {
             if ($this->_objectManager->get('Magento\\Checkout\\Model\\Session')->getUseNotice(true)) {
                 $this->messageManager->addNotice($e->getMessage());
             } else {
                 $this->messageManager->addError($e->getMessage());
             }
             $this->_redirect('*/*/history');
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('We cannot add this item to your shopping cart.'));
             $this->_redirect('checkout/cart');
         }
     }
     $cart->save();
     $this->_redirect('checkout/cart');
 }
示例#3
0
 /**
  * Print Order Action
  *
  * @return void
  */
 public function execute()
 {
     if (!$this->orderLoader->load($this->_request, $this->_response)) {
         return;
     }
     $this->_view->loadLayout('print');
     $this->_view->renderLayout();
 }
示例#4
0
 /**
  * Print Order Action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $result = $this->orderLoader->load($this->_request);
     if ($result instanceof \Magento\Framework\Controller\ResultInterface) {
         return $result;
     }
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->addHandle('print');
     return $resultPage;
 }
示例#5
0
文件: View.php 项目: aiesh/magento2
 /**
  * Order view page
  *
  * @return void
  */
 public function execute()
 {
     if (!$this->orderLoader->load($this->_request, $this->_response)) {
         return;
     }
     $this->_view->loadLayout();
     $this->_view->getLayout()->initMessages();
     $navigationBlock = $this->_view->getLayout()->getBlock('customer_account_navigation');
     if ($navigationBlock) {
         $navigationBlock->setActive('sales/order/history');
     }
     $this->_view->renderLayout();
 }
示例#6
0
 /**
  * Order view page
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $result = $this->orderLoader->load($this->_request);
     if ($result instanceof \Magento\Framework\Controller\ResultInterface) {
         return $result;
     }
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     /** @var \Magento\Framework\View\Element\Html\Links $navigationBlock */
     $navigationBlock = $resultPage->getLayout()->getBlock('customer_account_navigation');
     if ($navigationBlock) {
         $navigationBlock->setActive('sales/order/history');
     }
     return $resultPage;
 }