/** * Index action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Blocks')); return $resultPage; }
/** * Edit CMS block * * @return \Magento\Framework\Controller\ResultInterface * @SuppressWarnings(PHPMD.NPathComplexity) */ public function executeInternal() { // 1. Get ID and create model $id = $this->getRequest()->getParam('block_id'); $model = $this->_objectManager->create('Magento\\Cms\\Model\\Block'); // 2. Initial checking if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This block no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } // 3. Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } // 4. Register model to use later in blocks $this->_coreRegistry->register('cms_block', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); // 5. Build edit form $this->initPage($resultPage)->addBreadcrumb($id ? __('Edit Block') : __('New Block'), $id ? __('Edit Block') : __('New Block')); $resultPage->getConfig()->getTitle()->prepend(__('Blocks')); $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Block')); return $resultPage; }
/** * Default customer account page * * @return \Magento\Framework\View\Result\Page */ public function execute() { /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->set(__('My Account')); return $resultPage; }
/** * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Ves_Setup::export')->addBreadcrumb(__('Ves Setup'), __('Ves Setup'))->addBreadcrumb(__('Export'), __('Export')); return $resultPage; }
/** * @return void */ public function execute() { $ipId = $this->getRequest()->getParam('id'); /** @var \Rapidmage\Firewall\Model\Ip $model */ $model = $this->_ipFactory->create(); if ($ipId) { $model->load($ipId); if (!$model->getId()) { $this->messageManager->addError(__('This Ip no longer exists.')); $this->_redirect('*/*/'); return; } } // Restore previously entered form data from session $data = $this->_session->getIpData(true); if (!empty($data)) { $model->setData($data); } $this->_coreRegistry->register('firewall_blackip', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_resultPageFactory->create(); $resultPage->setActiveMenu('Rapidmage_Firewall::main_menu'); $resultPage->getConfig()->getTitle()->prepend(__('Firewall')); return $resultPage; }
/** * Product edit form * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ $storeManager = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface'); $storeId = (int) $this->getRequest()->getParam('store', 0); $store = $storeManager->getStore($storeId); $storeManager->setCurrentStore($store->getCode()); $productId = (int) $this->getRequest()->getParam('id'); $product = $this->productBuilder->build($this->getRequest()); if ($productId && !$product->getEntityId()) { $this->messageManager->addError(__('This product no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('catalog/*/'); } $this->_eventManager->dispatch('catalog_product_edit_action', ['product' => $product]); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->addHandle('catalog_product_' . $product->getTypeId()); $resultPage->setActiveMenu('Magento_Catalog::catalog_products'); $resultPage->getConfig()->getTitle()->prepend(__('Products')); $resultPage->getConfig()->getTitle()->prepend($product->getName()); if (!$this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->isSingleStoreMode() && ($switchBlock = $resultPage->getLayout()->getBlock('store_switcher'))) { $switchBlock->setDefaultStoreName(__('Default Values'))->setWebsiteIds($product->getWebsiteIds())->setSwitchUrl($this->getUrl('catalog/*/*', ['_current' => true, 'active_tab' => null, 'tab' => null, 'store' => null])); } $block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { $block->setStoreId($product->getStoreId()); } return $resultPage; }
/** * Send confirmation link to specified email * * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page */ public function execute() { if ($this->session->isLoggedIn()) { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('*/*/'); return $resultRedirect; } // try to confirm by email $email = $this->getRequest()->getPost('email'); if ($email) { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); try { $this->customerAccountManagement->resendConfirmation($email, $this->storeManager->getStore()->getWebsiteId()); $this->messageManager->addSuccess(__('Please check your email for confirmation key.')); } catch (InvalidTransitionException $e) { $this->messageManager->addSuccess(__('This email does not require confirmation.')); } catch (\Exception $e) { $this->messageManager->addException($e, __('Wrong email.')); $resultRedirect->setPath('*/*/*', ['email' => $email, '_secure' => true]); return $resultRedirect; } $this->session->setUsername($email); $resultRedirect->setPath('*/*/index', ['_secure' => true]); return $resultRedirect; } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('accountConfirmation')->setEmail($this->getRequest()->getParam('email', $email)); return $resultPage; }
/** * Initialize Layout and set breadcrumbs * * @return \Magento\Backend\Model\View\Result\Page */ protected function createPage() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('SweetTooth_Webhook::system_webhook')->addBreadcrumb(__('Webhooks'), __('Webhooks')); return $resultPage; }
/** * @return \Magento\Framework\View\Result\LayoutFactory */ public function executeInternal() { $resultLayout = $this->resultPageFactory->create(); $resultLayout->setStatusHeader(404, '1.1', 'Not Found'); $resultLayout->setHeader('Status', '404 File not found'); return $resultLayout; }
/** * Action to reconfigure cart item * * @return \Magento\Framework\View\Result\Page|\Magento\Framework\Controller\Result\Redirect */ public function execute() { // Extract item and product to configure $id = (int) $this->getRequest()->getParam('id'); $productId = (int) $this->getRequest()->getParam('product_id'); $quoteItem = null; if ($id) { $quoteItem = $this->cart->getQuote()->getItemById($id); } try { if (!$quoteItem || $productId != $quoteItem->getProduct()->getId()) { $this->messageManager->addError(__("We can't find the quote item.")); return $this->resultRedirectFactory->create()->setPath('checkout/cart'); } $params = new \Magento\Framework\Object(); $params->setCategoryId(false); $params->setConfigureMode(true); $params->setBuyRequest($quoteItem->getBuyRequest()); $resultPage = $this->resultPageFactory->create(); $this->_objectManager->get('Magento\\Catalog\\Helper\\Product\\View')->prepareAndRender($resultPage, $quoteItem->getProduct()->getId(), $this, $params); return $resultPage; } catch (\Exception $e) { $this->messageManager->addError(__('We cannot configure the product.')); $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e); return $this->_goBack(); } }
/** * Dispatch request * * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface * @throws \Magento\Framework\Exception\NotFoundException */ public function execute() { // 1. Get ID and create model $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create('Fastgento\\Storelocator\\Model\\Location'); // 2. Initial checking if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This block no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } // 3. Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); // 4. Register model to use later in blocks $this->_coreRegistry->register('location', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); if (is_array($data)) { if (isset($data['image']['delete'])) { $data['image'] = null; } else { unset($data['image']); } $model->addData($data); } // 5. Build edit form $this->initPage($resultPage)->addBreadcrumb($id ? __('Edit Location') : __('New Location'), $id ? __('Edit Location') : __('New Location')); //$resultPage->getConfig()->getTitle()->prepend(__('Locations')); //$resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getName() : __('New Location')); return $resultPage; }
/** * Promo quote edit action * * @return void * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create('Magento\\SalesRule\\Model\\Rule'); $this->_coreRegistry->register(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE, $model); $resultPage = $this->resultPageFactory->create(); if ($id) { $model->load($id); if (!$model->getRuleId()) { $this->messageManager->addError(__('This rule no longer exists.')); $this->_redirect('sales_rule/*'); return; } $resultPage->getLayout()->getBlock('promo_sales_rule_edit_tab_coupons')->setCanShow(true); } // set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getPageData(true); if (!empty($data)) { $model->addData($data); } $model->getConditions()->setFormName('sales_rule_form'); $model->getConditions()->setJsFormObject($model->getConditionsFieldSetId($model->getConditions()->getFormName())); $model->getActions()->setFormName('sales_rule_form'); $model->getActions()->setJsFormObject($model->getActionsFieldSetId($model->getActions()->getFormName())); $this->_initAction(); $this->_addBreadcrumb($id ? __('Edit Rule') : __('New Rule'), $id ? __('Edit Rule') : __('New Rule')); $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getRuleId() ? $model->getName() : __('New Cart Price Rule')); $this->_view->renderLayout(); }
/** * Init layout, menu and breadcrumb * * @return \Magento\Backend\Model\View\Result\Page */ protected function _initAction() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Magento_Sales::sales_invoice')->addBreadcrumb(__('Sales'), __('Sales'))->addBreadcrumb(__('Invoices'), __('Invoices')); return $resultPage; }
/** * Shopping cart display action * * @return \Magento\Framework\View\Result\Page */ public function execute() { $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->initMessages(); $resultPage->getConfig()->getTitle()->set(__('Shopping Cart')); return $resultPage; }
/** * 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; }
public function execute() { $this->resultPage = $this->resultPageFactory->create(); $this->resultPage->setActiveMenu('YourCompanyName_GridController::modelname'); $this->resultPage->getConfig()->getTitle()->set(__('GridController')); return $this->resultPage; }
/** * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { if (!$this->_validateProducts()) { return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['_current' => true]); } return $this->resultPageFactory->create(); }
/** * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\View\Result\Page */ public function execute() { $id = $this->getRequest()->getParam('post_id'); /** @var \Mageplaza\Blog\Model\Post $post */ $post = $this->initPost(); /** @var \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Mageplaza_Blog::post'); $resultPage->getConfig()->getTitle()->set(__('Posts')); if ($id) { $post->load($id); if (!$post->getId()) { $this->messageManager->addError(__('This Post no longer exists.')); $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('mageplaza_blog/*/edit', ['post_id' => $post->getId(), '_current' => true]); return $resultRedirect; } } $title = $post->getId() ? $post->getName() : __('New Post'); $resultPage->getConfig()->getTitle()->prepend($title); $data = $this->backendSession->getData('mageplaza_blog_post_data', true); if (!empty($data)) { $post->setData($data); } return $resultPage; }
/** * @return \Magento\Framework\View\Result\Page */ protected function _initAction() { // load layout, set active menu, breadcrumbs $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Pyvil_Blog::post')->addBreadcrumb(__('Blog'), __('Blog'))->addBreadcrumb(__('Manage blog posts'), __('Manage blog posts')); return $resultPage; }
/** * Resetting password handler * * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page */ public function executeInternal() { $resetPasswordToken = (string) $this->getRequest()->getParam('token'); $customerId = (int) $this->getRequest()->getParam('id'); $isDirectLink = $resetPasswordToken != '' && $customerId != 0; if (!$isDirectLink) { $resetPasswordToken = (string) $this->session->getRpToken(); $customerId = (int) $this->session->getRpCustomerId(); } try { $this->accountManagement->validateResetPasswordLinkToken($customerId, $resetPasswordToken); if ($isDirectLink) { $this->session->setRpToken($resetPasswordToken); $this->session->setRpCustomerId($customerId); $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('*/*/createpassword'); return $resultRedirect; } else { /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('resetPassword')->setCustomerId($customerId)->setResetPasswordLinkToken($resetPasswordToken); return $resultPage; } } catch (\Exception $exception) { $this->messageManager->addError(__('Your password reset link has expired.')); /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('*/*/forgotpassword'); return $resultRedirect; } }
public function execute() { $id = $this->getRequest()->getParam('author_id'); /** @var \Sample\News\Model\Author $author */ $author = $this->initAuthor(); /** @var \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Sample_News::author'); $resultPage->getConfig()->getTitle()->set(__('Authors')); if ($id) { $author->load($id); if (!$author->getId()) { $this->messageManager->addError(__('This author no longer exists.')); $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('sample_news/*/edit', ['author_id' => $author->getId(), '_current' => true]); return $resultRedirect; } } $title = $author->getId() ? $author->getName() : __('New Author'); $resultPage->getConfig()->getTitle()->append($title); $data = $this->backendSession->getData('sample_news_author_data', true); if (!empty($data)) { $author->setData($data); } return $resultPage; }
/** * @return \Magento\Backend\Model\View\Result\Page */ public function execute() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->prepend(__('Sentinel Login Logs')); return $resultPage; }
/** * instantiate result page object * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page */ public function getResultPage() { if (is_null($this->resultPage)) { $this->resultPage = $this->resultPageFactory->create(); } return $this->resultPage; }
/** * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\View\Result\Page */ public function execute() { $articleId = (int) $this->getRequest()->getParam('id'); $article = $this->articleFactory->create(); $article->load($articleId); if (!$article->isActive()) { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } $this->coreRegistry->register('current_article', $article); $resultPage = $this->resultPageFactory->create(); $title = $article->getMetaTitle() ?: $article->getName(); $resultPage->getConfig()->getTitle()->set($title); $resultPage->getConfig()->setDescription($article->getMetaDescription()); $resultPage->getConfig()->setKeywords($article->getMetaKeywords()); if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) { /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */ $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]); $breadcrumbsBlock->addCrumb('articles', ['label' => __('Articles'), 'link' => $this->urlModel->getListUrl()]); $breadcrumbsBlock->addCrumb('article-' . $article->getId(), ['label' => $article->getName()]); } } return $resultPage; }
/** * Init actions * * @return \Magento\Backend\Model\View\Result\Page */ protected function createPage() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Magento_Backend::system_store')->addBreadcrumb(__('System'), __('System'))->addBreadcrumb(__('Manage Stores'), __('Manage Stores')); return $resultPage; }
public function execute() { // 1. Get ID and create model $id = $this->getRequest()->getParam("cat_id"); $model = $this->_objectManager->create("OsmanSorkar\\Blog\\Model\\Category"); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__("This Category no longer exists")); /** \Magento\Backend\Model\View\Result\Redirct $resultRedirct */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } // 3. Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } // 4. Register model to use later in blocks $this->_coreRegistry->register('blog_category', $model); // 5. Build edit form /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Ashsmith_Blog::category'); $resultPage->addBreadcrumb(__('Blog Category Edit'), __('Blog Category Edit')); $resultPage->addBreadcrumb(__('Manage Blog Category'), __('Manage Blog Category')); $resultPage->getConfig()->getTitle()->prepend(__('Blog Category Edit')); return $resultPage; }
/** * Return a blog post from given post id. * * @param Action $action * @param null $postId * @return \Magento\Framework\View\Result\Page|bool */ public function prepareResultPost(Action $action, $postId = null) { if ($postId !== null && $postId !== $this->_post->getId()) { $delimiterPosition = strrpos($postId, '|'); if ($delimiterPosition) { $postId = substr($postId, 0, $delimiterPosition); } if (!$this->_post->load($postId)) { return false; } } if (!$this->_post->getId()) { return false; } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); // We can add our own custom page handles for layout easily. $resultPage->addHandle('blog_post_view'); // This will generate a layout handle like: blog_post_view_id_1 // giving us a unique handle to target specific blog posts if we wish to. $resultPage->addPageLayoutHandles(['id' => $this->_post->getId()]); // Magento is event driven after all, lets remember to dispatch our own, to help people // who might want to add additional functionality, or filter the posts somehow! $this->_eventManager->dispatch('ashsmith_blog_post_render', ['post' => $this->_post, 'controller_action' => $action]); return $resultPage; }
/** * 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; } }
/** * 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; } }
/** * Index action * * @return \Magento\Backend\Model\View\Result\Page */ public function execute() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('layout.view.elements'); return $resultPage; }