/** * 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)); }
/** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator * @param \Magento\Checkout\Model\Cart $cart */ public function __construct(Framework\App\Action\Context $context, Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, \Magento\Checkout\Model\Cart $cart) { parent::__construct($context, $scopeConfig, $checkoutSession, $storeManager, $formKeyValidator, $cart); }
/** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator * @param CustomerCart $cart * @param \Magento\Quote\Model\QuoteRepository $quoteRepository * @codeCoverageIgnore */ public function __construct(Framework\App\Action\Context $context, Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, CustomerCart $cart, \Magento\Quote\Model\QuoteRepository $quoteRepository) { $this->quoteRepository = $quoteRepository; parent::__construct($context, $scopeConfig, $checkoutSession, $storeManager, $formKeyValidator, $cart); }
/** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator * @param \Magento\Checkout\Model\Cart $cart * @param \Magento\SalesRule\Model\CouponFactory $couponFactory * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository * @codeCoverageIgnore */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, \Magento\Checkout\Model\Cart $cart, \Magento\SalesRule\Model\CouponFactory $couponFactory, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository) { parent::__construct($context, $scopeConfig, $checkoutSession, $storeManager, $formKeyValidator, $cart); $this->couponFactory = $couponFactory; $this->quoteRepository = $quoteRepository; }
/** * 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)); }
/** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator * @param \Magento\Checkout\Model\Cart $cart * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @codeCoverageIgnore */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, \Magento\Checkout\Model\Cart $cart, \Magento\Framework\View\Result\PageFactory $resultPageFactory) { parent::__construct($context, $scopeConfig, $checkoutSession, $storeManager, $formKeyValidator, $cart); $this->resultPageFactory = $resultPageFactory; }
/** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator * @param \Magento\Checkout\Model\Cart $cart * @param \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Quote\Model\QuoteRepository $quoteRepository */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, \Magento\Checkout\Model\Cart $cart, \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory, \Magento\Quote\Model\QuoteRepository $quoteRepository) { parent::__construct($context, $scopeConfig, $checkoutSession, $storeManager, $formKeyValidator, $cart, $resultRedirectFactory); $this->quoteRepository = $quoteRepository; }