/** * Resolve response * * @param string $backUrl * @param \Magento\Catalog\Model\Product $product * @return $this|\Magento\Framework\Controller\Result\Redirect */ protected function goBack($backUrl = null, $product = null) { if (!$this->getRequest()->isAjax()) { return parent::_goBack($backUrl); } $result = []; if ($backUrl || ($backUrl = $this->getBackUrl())) { $result['backUrl'] = $backUrl; } else { if ($product && !$product->getIsSalable()) { $result['product'] = ['statusText' => __('Out of stock')]; } } $this->getResponse()->representJson($this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data')->jsonEncode($result)); }
/** * Resolve response * * @param string $backUrl * @param \Magento\Catalog\Model\Product $product * @return $this|\Magento\Framework\Controller\Result\Redirect */ protected function goBack($backUrl = null, $product = null) { if (!$this->getRequest()->isAjax()) { return parent::_goBack($backUrl); } $result = []; if ($backUrl || ($backUrl = $this->getBackUrl())) { $result['backUrl'] = $backUrl; } else { $this->_view->loadLayout(['default'], true, true, false); $layout = $this->_view->getLayout(); $result['messages'] = $layout->getBlock('global_messages')->toHtml(); if ($this->_checkoutSession->getCartWasUpdated()) { $result['minicart'] = $layout->getBlock('minicart')->toHtml(); } if ($product && !$product->getIsSalable()) { $result['product'] = ['statusText' => __('Out of stock')]; } } $this->getResponse()->representJson($this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data')->jsonEncode($result)); }