/** * Add comment to shipment history * * @return void */ public function execute() { try { $this->getRequest()->setParam('shipment_id', $this->getRequest()->getParam('id')); $data = $this->getRequest()->getPost('comment'); if (empty($data['comment'])) { throw new \Magento\Framework\Exception\LocalizedException(__("The comment text field cannot be empty.")); } $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(); $shipment->addComment($data['comment'], isset($data['is_customer_notified']), isset($data['is_visible_on_front'])); $this->shipmentCommentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']); $shipment->save(); $resultLayout = $this->resultLayoutFactory->create(); $resultLayout->addDefaultHandle(); $response = $resultLayout->getLayout()->getBlock('shipment_comments')->toHtml(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $response = ['error' => true, 'message' => $e->getMessage()]; } catch (\Exception $e) { $response = ['error' => true, 'message' => __('Cannot add new comment.')]; } if (is_array($response)) { $response = $this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data')->jsonEncode($response); $this->getResponse()->representJson($response); } else { $this->getResponse()->setBody($response); } }
/** * Export invoice grid to CSV format * * @return ResponseInterface */ public function execute() { $fileName = 'invoices.csv'; /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ $exportBlock = $this->resultLayoutFactory->create()->getLayout()->getChildBlock('sales.invoice.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile(), DirectoryList::VAR_DIR); }
/** * Get crosssell products grid * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->productBuilder->build($this->getRequest()); $resultLayout = $this->resultLayoutFactory->create(); $resultLayout->getLayout()->getBlock('catalog.product.edit.tab.crosssell')->setProductsRelated($this->getRequest()->getPost('products_crosssell', null)); return $resultLayout; }
/** * Export shipment grid to CSV format * * @return ResponseInterface */ public function execute() { $fileName = 'shipments.csv'; /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultLayoutFactory->create(); $grid = $resultLayout->getLayout()->getChildBlock('sales.shipment.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); }
/** * Export credit memo grid to Excel XML format * * @return ResponseInterface */ public function execute() { $fileName = 'creditmemos.xml'; $resultLayout = $this->resultLayoutFactory->create(); $grid = $resultLayout->getLayout()->getChildBlock('sales.creditmemo.grid', 'grid.export'); $excelFile = $grid->getExcelFile($fileName); return $this->_fileFactory->create($fileName, $excelFile, DirectoryList::VAR_DIR); }
/** * @return mixed */ public function execute() { $this->initArticle(); $resultLayout = $this->resultLayoutFactory->create(); $productsBlock = $resultLayout->getLayout()->getBlock('article.edit.tab.product'); if ($productsBlock) { $productsBlock->setArticleProducts($this->getRequest()->getPost('article_products', null)); } return $resultLayout; }
/** * @return mixed */ public function execute() { $this->_initCategory(); $resultLayout = $this->resultLayoutFactory->create(); $articlesBlock = $resultLayout->getLayout()->getBlock('category.gemtoo_blog.article.grid'); if ($articlesBlock) { $articlesBlock->setCategoryArticles($this->getRequest()->getPost('category_gemtoo_blog_articles', null)); } return $resultLayout; }
/** * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->initAuthor(); $resultLayout = $this->resultLayoutFactory->create(); /** @var \Sample\News\Block\Adminhtml\Author\Edit\Tab\Product $productsBlock */ $productsBlock = $resultLayout->getLayout()->getBlock('author.edit.tab.product'); if ($productsBlock) { $productsBlock->setAuthorProducts($this->getRequest()->getPost('author_products', null)); } return $resultLayout; }
/** * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->initCategory(); $resultLayout = $this->resultLayoutFactory->create(); /** @var \Mageplaza\Blog\Block\Adminhtml\Category\Edit\Tab\Post $postsBlock */ $postsBlock = $resultLayout->getLayout()->getBlock('category.edit.tab.post'); if ($postsBlock) { $postsBlock->setCategoryPosts($this->getRequest()->getPost('category_posts', null)); } return $resultLayout; }
/** * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->_initCategory(); $resultLayout = $this->resultLayoutFactory->create(); /** @var \Sample\News\Block\Adminhtml\Catalog\Category\Tab\Author $authorsBlock */ $authorsBlock = $resultLayout->getLayout()->getBlock('category.sample_news.author.grid'); if ($authorsBlock) { $authorsBlock->setCategoryAuthors($this->getRequest()->getPost('category_sample_news_authors', null)); } return $resultLayout; }
/** * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->initPost(); $resultLayout = $this->resultLayoutFactory->create(); /** @var \Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Tag $tagsBlock */ $tagsBlock = $resultLayout->getLayout()->getBlock('post.edit.tab.tag'); if ($tagsBlock) { $tagsBlock->setPostTags($this->getRequest()->getPost('post_tags', null)); } return $resultLayout; }
/** * Retrieve params and put javascript into iframe * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $redirectParams = $this->getRequest()->getParams(); $params = []; if (!empty($redirectParams['success']) && isset($redirectParams['x_invoice_num']) && isset($redirectParams['controller_action_name'])) { $params['redirect_parent'] = $this->helper->getSuccessOrderUrl($redirectParams); $directpostSession = $this->_objectManager->get('Magento\\Authorizenet\\Model\\Directpost\\Session'); $directpostSession->unsetData('quote_id'); //cancel old order $oldOrder = $this->_getOrderCreateModel()->getSession()->getOrder(); if ($oldOrder->getId()) { /* @var $order \Magento\Sales\Model\Order */ $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->loadByIncrementId($redirectParams['x_invoice_num']); if ($order->getId()) { $oldOrder->cancel()->save(); $order->save(); $this->_getOrderCreateModel()->getSession()->unsOrderId(); } } //clear sessions $this->_getSession()->clearStorage(); $directpostSession->removeCheckoutOrderIncrementId($redirectParams['x_invoice_num']); $this->_objectManager->get('Magento\\Backend\\Model\\Session')->clearStorage(); $this->messageManager->addSuccess(__('You created the order.')); } if (!empty($redirectParams['error_msg'])) { $cancelOrder = empty($redirectParams['x_invoice_num']); $this->_returnQuote($cancelOrder, $redirectParams['error_msg']); } $this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams)); return $this->resultLayoutFactory->create(); }
/** * @return mixed */ public function execute() { $productId = (int) $this->getRequest()->getParam('id'); $product = $this->productBuilder->build($this->getRequest()); if ($productId && !$product->getId()) { $this->messageManager->addError(__('This product no longer exists.')); $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('catalog/*/'); } $resultLayout = $this->resultLayoutFactory->create(); $articlesBlock = $resultLayout->getLayout()->getBlock('gemtoo_blog.article'); if ($articlesBlock) { $articlesBlock->setProductArticles($this->getRequest()->getPost('product_articles', null)); } return $resultLayout; }
/** * @return ResultInterface */ public function execute() { $parameters = []; try { $response = $this->transaction->getResponseObject($this->getRequest()->getPostValue()); $this->responseValidator->validate($response, $this->transparent); $this->transaction->savePaymentInQuote($response); } catch (LocalizedException $exception) { $parameters['error'] = true; $parameters['error_msg'] = $exception->getMessage(); } $this->coreRegistry->register(Iframe::REGISTRY_KEY, $parameters); $resultLayout = $this->resultLayoutFactory->create(); $resultLayout->addDefaultHandle(); $resultLayout->getLayout()->getUpdate()->load(['transparent_payment_response']); return $resultLayout; }
/** * Index action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $storeId = (int) $this->getRequest()->getParam('store'); try { $this->_objectManager->get('Magento\\Cms\\Helper\\Wysiwyg\\Images')->getCurrentPath(); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); } $this->_initAction(); /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultLayoutFactory->create(); $resultLayout->addHandle('overlay_popup'); $block = $resultLayout->getLayout()->getBlock('wysiwyg_images.js'); if ($block) { $block->setStoreId($storeId); } return $resultLayout; }
/** * @return $this|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Layout */ public function execute() { $productId = (int) $this->getRequest()->getParam('id'); $product = $this->productBuilder->build($this->getRequest()); if ($productId && !$product->getId()) { $this->messageManager->addError(__('This product no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('catalog/*/'); } $resultLayout = $this->resultLayoutFactory->create(); /** @var \Sample\News\Block\Adminhtml\Catalog\Product\Edit\Tab\Author $authorsBlock */ $authorsBlock = $resultLayout->getLayout()->getBlock('sample_news.author'); if ($authorsBlock) { $authorsBlock->setProductAuthors($this->getRequest()->getPost('product_authors', null)); } return $resultLayout; }
/** * Init composite product configuration layout * * $isOk - true or false, whether action was completed nicely or with some error * If $isOk is FALSE (some error during configuration), so $productType must be null * * @param bool $isOk * @param string $productType * @return \Magento\Framework\View\Result\Layout */ protected function _initConfigureResultLayout($isOk, $productType) { $resultLayout = $this->resultLayoutFactory->create(); if ($isOk) { $resultLayout->addHandle('CATALOG_PRODUCT_COMPOSITE_CONFIGURE')->addHandle('catalog_product_view_type_' . $productType); } else { $resultLayout->addHandle('CATALOG_PRODUCT_COMPOSITE_CONFIGURE_ERROR'); } return $resultLayout; }
/** * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->_setTypeId(); return $this->resultLayoutFactory->create(); }
/** * Index action * * @return \Magento\Backend\Model\View\Result\Page */ public function execute() { /** @var \Magento\Framework\View\Result\Layout $resultPage */ $resultPage = $this->resultPageFactory->create(); return $resultPage; }
/** * Creditmemo grid * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $resultLayout = $this->resultLayoutFactory->create(); return $resultLayout; }
/** * Get alerts stock grid * * @return \Magento\Framework\Controller\ResultInterface */ public function executeInternal() { return $this->resultLayoutFactory->create(); }
/** * @return \Magento\Framework\View\Result\Layout */ public function execute() { $resultLayout = $this->resultLayoutFactory->create(); $resultLayout->getLayout()->getBlock('carousel.slider.edit.tab.banners')->setInBanner($this->getRequest()->getPost('banner', null)); return $resultLayout; }
/** * Export invoice grid to Excel XML format * * @return ResponseInterface */ public function execute() { $fileName = 'invoices.xml'; $exportBlock = $this->resultLayoutFactory->create()->getLayout()->getChildBlock('sales.invoice.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile($fileName), DirectoryList::VAR_DIR); }
/** * Show custom options in JSON format for specified products * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->registry->register('import_option_products', $this->getRequest()->getPost('products')); return $this->resultLayoutFactory->create(); }
/** * Get options fieldset block * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $this->productBuilder->build($this->getRequest()); return $this->resultLayoutFactory->create(); }
/** * Contents action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { try { $this->_initAction()->_saveSessionCurrentPath(); /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultLayoutFactory->create(); return $resultLayout; } catch (\Exception $e) { $result = ['error' => true, 'message' => $e->getMessage()]; /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); $resultJson->setData($result); return $resultJson; } }