public function testGetIsSalableHasDataIsSaleable()
 {
     $typeInstanceMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type\\Simple', [], [], '', false);
     $this->model->setTypeInstance($typeInstanceMock);
     $this->model->setData('is_saleable', true);
     $this->model->setData('is_salable', false);
     self::assertTrue($this->model->getIsSalable());
 }
Example #2
0
 /**
  * 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));
 }
Example #3
0
 /**
  * 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));
 }
 /**
  * {@inheritdoc}
  */
 public function getIsSalable()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getIsSalable');
     if (!$pluginInfo) {
         return parent::getIsSalable();
     } else {
         return $this->___callPlugins('getIsSalable', func_get_args(), $pluginInfo);
     }
 }