/** * Create new product page * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { if (!$this->getRequest()->getParam('set')) { return $this->resultForwardFactory->create()->forward('noroute'); } $product = $this->productBuilder->build($this->getRequest()); $productData = $this->getRequest()->getPost('product'); if (!$productData) { $sessionData = $this->_session->getProductData(true); if (!empty($sessionData['product'])) { $productData = $sessionData['product']; } } if ($productData) { $stockData = isset($productData['stock_data']) ? $productData['stock_data'] : []; $productData['stock_data'] = $this->stockFilter->filter($stockData); $product = $this->getInitializationHelper()->initializeFromData($product, $productData); } $this->_eventManager->dispatch('catalog_product_new_action', ['product' => $product]); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); if ($this->getRequest()->getParam('popup')) { $resultPage->addHandle(['popup', 'catalog_product_' . $product->getTypeId()]); } else { $resultPage->addHandle(['catalog_product_' . $product->getTypeId()]); $resultPage->setActiveMenu('Magento_Catalog::catalog_products'); $resultPage->getConfig()->getTitle()->prepend(__('Products')); $resultPage->getConfig()->getTitle()->prepend(__('New Product')); } $block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { $block->setStoreId($product->getStoreId()); } return $resultPage; }
/** * @return ResponseInterface|\Magento\Backend\Model\View\Result\Forward */ public function executeInternal() { /** @see \Magento\Sales\Controller\Adminhtml\Order\Invoice */ $creditmemoId = $this->getRequest()->getParam('creditmemo_id'); if ($creditmemoId) { $creditmemo = $this->creditmemoRepository->get($creditmemoId); if ($creditmemo) { $pdf = $this->_objectManager->create( 'Magento\Sales\Model\Order\Pdf\Creditmemo' )->getPdf( [$creditmemo] ); $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'creditmemo' . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf' ); } } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } }
/** * Add new category form * * @return \Magento\Backend\Model\View\Result\Forward */ public function executeInternal() { $this->_objectManager->get('Magento\\Backend\\Model\\Auth\\Session')->unsActiveTabId(); /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('edit'); }
/** * @return ResponseInterface|\Magento\Backend\Model\View\Result\Forward */ public function executeInternal() { $shipmentId = $this->getRequest()->getParam('shipment_id'); if ($shipmentId) { $shipment = $this->_objectManager->create('Magento\Sales\Model\Order\Shipment')->load($shipmentId); if ($shipment) { $pdf = $this->_objectManager->create( 'Magento\Sales\Model\Order\Pdf\Shipment' )->getPdf( [$shipment] ); $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'packingslip' . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf' ); } } else { /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('noroute'); } }
/** * forward to edit * * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { $this->_getSession()->unsMageplazaBlogCategoryActiveTabId(); $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('edit'); return $resultForward; }
/** * Creditmemo information page * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Forward */ public function executeInternal() { $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('sales_creditmemo_view') ->updateBackButtonUrl($this->getRequest()->getParam('come_from')); $resultPage->setActiveMenu('Magento_Sales::sales_creditmemo'); if ($creditmemo->getInvoice()) { $resultPage->getConfig()->getTitle()->prepend( __("View Memo for #%1", $creditmemo->getInvoice()->getIncrementId()) ); } else { $resultPage->getConfig()->getTitle()->prepend(__("View Memo")); } return $resultPage; } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } }
/** * Creditmemo create page * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Forward */ public function execute() { $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { if ($comment = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getCommentText(true)) { $creditmemo->setCommentText($comment); } $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Magento_Sales::sales_order'); $resultPage->getConfig()->getTitle()->prepend(__('Credit Memos')); if ($creditmemo->getInvoice()) { $resultPage->getConfig()->getTitle()->prepend(__("New Memo for #%1", $creditmemo->getInvoice()->getIncrementId())); } else { $resultPage->getConfig()->getTitle()->prepend(__("New Memo")); } return $resultPage; } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } }
/** * Void creditmemo action * * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Backend\Model\View\Result\Forward */ public function execute() { $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { try { $creditmemo->void(); $transactionSave = $this->_objectManager->create('Magento\\Framework\\DB\\Transaction'); $transactionSave->addObject($creditmemo); $transactionSave->addObject($creditmemo->getOrder()); if ($creditmemo->getInvoice()) { $transactionSave->addObject($creditmemo->getInvoice()); } $transactionSave->save(); $this->messageManager->addSuccess(__('You voided the credit memo.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t void the credit memo.')); } $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('sales/*/view', ['creditmemo_id' => $creditmemo->getId()]); return $resultRedirect; } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } }
/** * Invoice information page * * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { $resultForward = $this->resultForwardFactory->create(); if ($this->getRequest()->getParam('invoice_id')) { $resultForward->setController('order_invoice')->setParams(['come_from' => 'invoice'])->forward('view'); } else { $resultForward->forward('noroute'); } return $resultForward; }
/** * Shipment information page * * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); if ($this->getRequest()->getParam('shipment_id')) { $resultForward->setController('order_shipment')->setModule('admin')->setParams(['come_from' => 'shipment'])->forward('view'); return $resultForward; } else { return $resultForward->forward('noroute'); } }
/** * Creditmemo information page * * @return \Magento\Backend\Model\View\Result\Forward */ public function executeInternal() { $resultForward = $this->resultForwardFactory->create(); if ($this->getRequest()->getParam('creditmemo_id')) { $resultForward->setController('order_creditmemo'); $resultForward->setParams(['come_from' => 'sales_creditmemo']); $resultForward->forward('view'); } else { $resultForward->forward('noroute'); } return $resultForward; }
/** * @return ResponseInterface|void */ public function execute() { $invoiceId = $this->getRequest()->getParam('invoice_id'); if ($invoiceId) { $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId); if ($invoice) { $pdf = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Pdf\\Invoice')->getPdf([$invoice]); $date = $this->_objectManager->get('Magento\\Framework\\Stdlib\\DateTime\\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create('invoice' . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf'); } } else { return $this->resultForwardFactory->create()->forward('noroute'); } }
/** * Notify user * * @return \Magento\Backend\Model\View\Result\Forward|\Magento\Backend\Model\View\Result\Redirect */ public function execute() { $invoiceId = $this->getRequest()->getParam('invoice_id'); if (!$invoiceId) { return $this->resultForwardFactory->create()->forward('noroute'); } $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId); if (!$invoice) { return $this->resultForwardFactory->create()->forward('noroute'); } $this->_objectManager->create('Magento\\Sales\\Model\\Order\\InvoiceNotifier')->notify($invoice); $this->messageManager->addSuccess(__('We sent the message.')); return $this->resultRedirectFactory->create()->setPath('sales/invoice/view', ['order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId]); }
/** * Notify user * * @return \Magento\Backend\Model\View\Result\Forward|\Magento\Backend\Model\View\Result\Redirect */ public function execute() { $invoiceId = $this->getRequest()->getParam('invoice_id'); if (!$invoiceId) { return $this->resultForwardFactory->create()->forward('noroute'); } $invoice = $this->_objectManager->create('Magento\\Sales\\Api\\InvoiceRepositoryInterface')->get($invoiceId); if (!$invoice) { return $this->resultForwardFactory->create()->forward('noroute'); } $this->_objectManager->create('Magento\\Sales\\Api\\InvoiceManagementInterface')->notify($invoice->getEntityId()); $this->messageManager->addSuccess(__('You sent the message.')); return $this->resultRedirectFactory->create()->setPath('sales/invoice/view', ['order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId]); }
/** * Shipment information page * * @return void */ public function execute() { $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); $shipment = $this->shipmentLoader->load(); if ($shipment) { $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('sales_shipment_view')->updateBackButtonUrl($this->getRequest()->getParam('come_from')); $resultPage->setActiveMenu('Magento_Sales::sales_shipment'); $resultPage->getConfig()->getTitle()->prepend(__('Shipments')); $resultPage->getConfig()->getTitle()->prepend("#" . $shipment->getIncrementId()); return $resultPage; } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } }
/** * Save creditmemo * We can save only new creditmemo. Existing creditmemos are not editable * * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Backend\Model\View\Result\Forward * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $resultRedirect = $this->resultRedirectFactory->create(); $data = $this->getRequest()->getPost('creditmemo'); if (!empty($data['comment_text'])) { $this->_getSession()->setCommentText($data['comment_text']); } try { $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { if (!$creditmemo->isValidGrandTotal()) { throw new \Magento\Framework\Exception\LocalizedException(__('The credit memo\'s total must be positive.')); } if (!empty($data['comment_text'])) { $creditmemo->addComment($data['comment_text'], isset($data['comment_customer_notify']), isset($data['is_visible_on_front'])); $creditmemo->setCustomerNote($data['comment_text']); $creditmemo->setCustomerNoteNotify(isset($data['comment_customer_notify'])); } if (isset($data['do_offline'])) { //do not allow online refund for Refund to Store Credit if (!$data['do_offline'] && !empty($data['refund_customerbalance_return_enable'])) { throw new \Magento\Framework\Exception\LocalizedException(__('Cannot create online refund for Refund to Store Credit.')); } } $creditmemoManagement = $this->_objectManager->create('Magento\\Sales\\Api\\CreditmemoManagementInterface'); $creditmemoManagement->refund($creditmemo, (bool) $data['do_offline'], !empty($data['send_email'])); if (!empty($data['send_email'])) { $this->creditmemoSender->send($creditmemo); } $this->messageManager->addSuccess(__('You created the credit memo.')); $this->_getSession()->getCommentText(true); $resultRedirect->setPath('sales/order/view', ['order_id' => $creditmemo->getOrderId()]); return $resultRedirect; } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); $this->_getSession()->setFormData($data); } catch (\Exception $e) { $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e); $this->messageManager->addError(__('We can\'t save the credit memo right now.')); } $resultRedirect->setPath('sales/*/new', ['_current' => true]); return $resultRedirect; }
/** * Cancel creditmemo action * * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Backend\Model\View\Result\Forward */ public function execute() { $creditmemoId = $this->getRequest()->getParam('creditmemo_id'); if ($creditmemoId) { try { $creditmemoManagement = $this->_objectManager->create('Magento\\Sales\\Api\\CreditmemoManagementInterface'); $creditmemoManagement->cancel($creditmemoId); $this->messageManager->addSuccess(__('The credit memo has been canceled.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Credit memo has not been canceled.')); } $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('sales/*/view', ['creditmemo_id' => $creditmemoId]); return $resultRedirect; } else { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } }
/** * Create new product page * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { if (!$this->getRequest()->getParam('set')) { return $this->resultForwardFactory->create()->forward('noroute'); } $product = $this->productBuilder->build($this->getRequest()); $this->_eventManager->dispatch('catalog_product_new_action', ['product' => $product]); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); if ($this->getRequest()->getParam('popup')) { $resultPage->addHandle(['popup', 'catalog_product_' . $product->getTypeId()]); } else { $resultPage->addHandle(['catalog_product_' . $product->getTypeId()]); $resultPage->setActiveMenu('Magento_Catalog::catalog_products'); $resultPage->getConfig()->getTitle()->prepend(__('Products')); $resultPage->getConfig()->getTitle()->prepend(__('New Product')); } $block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { $block->setStoreId($product->getStoreId()); } return $resultPage; }
/** * @return \Magento\Backend\Model\View\Result\Forward */ public function executeInternal() { return $this->resultForwardFactory->create()->forward('edit'); }
/** * forward to edit * * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('edit'); return $resultForward; }
/** * execute action * * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('edit'); }
/** * Edit DemoList item. Forward to new action. * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { return $this->resultForwardFactory->create()->forward('new'); }
/** * Create new CMS block * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('edit'); }