Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * @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;
 }
Example #7
0
 /**
  * @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;
 }
Example #8
0
 /**
  * @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 \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;
 }
 /**
  * @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;
 }
Example #12
0
 protected function setUp()
 {
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['getPostValue'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->viewMock = $this->getMockBuilder('Magento\\Framework\\App\\ViewInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->coreRegistryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['register'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->setMethods(['addDefaultHandle', 'getLayout', 'getUpdate', 'load'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\LayoutFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($this->resultLayoutMock);
     $this->transactionMock = $this->getMockBuilder('Magento\\Paypal\\Model\\Payflow\\Service\\Response\\Transaction')->setMethods(['getResponseObject', 'validateResponse', 'savePaymentInQuote'])->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('\\Magento\\Framework\\App\\Action\\Context')->setMethods(['getRequest'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->responseValidatorMock = $this->getMockBuilder('Magento\\Paypal\\Model\\Payflow\\Service\\Response\\Validator\\ResponseValidator')->disableOriginalConstructor()->getMock();
     $this->object = new Response($this->contextMock, $this->coreRegistryMock, $this->transactionMock, $this->responseValidatorMock, $this->resultLayoutFactoryMock);
 }
Example #13
0
 /**
  * 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();
 }
 protected function setUp()
 {
     $this->directpostSessionMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Session')->setMethods(['getLastOrderIncrementId', 'removeCheckoutOrderIncrementId', 'isCheckoutOrderIncrementIdExist', 'unsetData'])->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->setMethods(['getId', 'getState', 'getIncrementId', 'registerCancellation', 'loadByIncrementId', 'save'])->disableOriginalConstructor()->getMock();
     $this->adminOrderCreateMock = $this->getMockBuilder('Magento\\Sales\\Model\\AdminOrder\\Create')->setMethods(['getSession'])->disableOriginalConstructor()->getMock();
     $sessionMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->getMock();
     $this->sessionQuoteMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session\\Quote')->setMethods(['getOrder', 'clearStorage'])->disableOriginalConstructor()->getMock();
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap([['Magento\\Authorizenet\\Model\\Directpost\\Session', $this->directpostSessionMock], ['Magento\\Sales\\Model\\AdminOrder\\Create', $this->adminOrderCreateMock], ['Magento\\Backend\\Model\\Session\\Quote', $this->sessionQuoteMock], ['Magento\\Backend\\Model\\Session', $sessionMock]]);
     $this->objectManagerMock->expects($this->any())->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($this->orderMock);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['getParams'])->getMockForAbstractClass();
     $responseMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface');
     $redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
     $this->contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->setMethods(['getObjectManager', 'getRequest', 'getResponse', 'getRedirect', 'getMessageManager'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getResponse')->willReturn($responseMock);
     $this->contextMock->expects($this->any())->method('getRedirect')->willReturn($redirectMock);
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->productHelperMock = $this->getMockBuilder('Magento\\Catalog\\Helper\\Product')->disableOriginalConstructor()->getMock();
     $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock();
     $this->resultPageFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->getMock();
     $this->forwardFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->coreRegistryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['register'])->disableOriginalConstructor()->getMock();
     $resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\LayoutFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($resultLayoutMock);
     $this->helperMock = $this->getMockBuilder('Magento\\Authorizenet\\Helper\\Backend\\Data')->setMethods(['getSuccessOrderUrl'])->disableOriginalConstructor()->getMock();
     $this->controller = new Redirect($this->contextMock, $this->productHelperMock, $this->escaperMock, $this->resultPageFactoryMock, $this->forwardFactoryMock, $this->coreRegistryMock, $this->resultLayoutFactoryMock, $this->helperMock);
 }
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $data = ['comment' => 'comment'];
     $result = 'result-html';
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $resultLayoutMock = $this->getMock('Magento\\Framework\\View\\Result\\Layout', ['getBlock', 'getDefaultLayoutHandle', 'addDefaultHandle', 'getLayout'], [], '', false);
     $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId);
     $this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue($data));
     $this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, $shipmentId], ['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $tracking]]));
     $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
     $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
     $this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
     $this->shipmentMock->expects($this->once())->method('addComment');
     $this->shipmentCommentSenderMock->expects($this->once())->method('send');
     $this->shipmentMock->expects($this->once())->method('save');
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $blockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\View\\Comments', ['toHtml'], [], '', false);
     $blockMock->expects($this->once())->method('toHtml')->willReturn($result);
     $layoutMock->expects($this->once())->method('getBlock')->with('shipment_comments')->willReturn($blockMock);
     $resultLayoutMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
     $resultLayoutMock->expects($this->once())->method('addDefaultHandle');
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultLayoutMock));
     $this->responseMock->expects($this->once())->method('setBody')->with($result);
     $this->assertNull($this->controller->execute());
 }
Example #16
0
 /**
  * @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;
 }
Example #17
0
 public function testNewsletterAction()
 {
     $subscriberMock = $this->getMock('\\Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($this->resultLayoutMock);
     $subscriberMock->expects($this->once())->method('loadByCustomerId');
     $this->_objectManager->expects($this->at(1))->method('create')->with('Magento\\Newsletter\\Model\\Subscriber')->will($this->returnValue($subscriberMock));
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Layout', $this->_testedObject->execute());
 }
Example #18
0
 /**
  * @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;
 }
Example #19
0
 /**
  * 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;
 }
Example #20
0
 /**
  * @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;
 }
Example #21
0
 /**
  * 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;
 }
Example #22
0
 /**
  * @return \Magento\Framework\View\Result\Layout
  */
 public function execute()
 {
     $this->_setTypeId();
     return $this->resultLayoutFactory->create();
 }
Example #23
0
 /**
  * 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;
 }
Example #24
0
 /**
  * Creditmemo grid
  *
  * @return \Magento\Framework\View\Result\Layout
  */
 public function execute()
 {
     $resultLayout = $this->resultLayoutFactory->create();
     return $resultLayout;
 }
Example #25
0
 /**
  * Get options fieldset block
  *
  * @return \Magento\Framework\View\Result\Layout
  */
 public function execute()
 {
     $this->productBuilder->build($this->getRequest());
     return $this->resultLayoutFactory->create();
 }
Example #26
0
 /**
  * Get alerts stock grid
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function executeInternal()
 {
     return $this->resultLayoutFactory->create();
 }
 /**
  * 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();
 }
 /**
  * @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;
 }
Example #29
0
 /**
  * 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);
 }
Example #30
-1
 /**
  * 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;
     }
 }