/** * @covers \Magento\Catalog\Model\Product::isSalable * @covers \Magento\Catalog\Model\Product::isSaleable * @covers \Magento\Catalog\Model\Product::isAvailable * @covers \Magento\Catalog\Model\Product::isInStock */ public function testIsSalable() { $this->_model->load(1); // fixture $this->assertTrue((bool) $this->_model->isSalable()); $this->assertTrue((bool) $this->_model->isSaleable()); $this->assertTrue((bool) $this->_model->isAvailable()); $this->assertTrue($this->_model->isInStock()); $this->_model->setStatus(0); $this->assertFalse((bool) $this->_model->isSalable()); $this->assertFalse((bool) $this->_model->isSaleable()); $this->assertFalse((bool) $this->_model->isAvailable()); $this->assertFalse($this->_model->isInStock()); }
/** * @covers \Magento\Catalog\Model\Product::isSalable * @covers \Magento\Catalog\Model\Product::isSaleable * @covers \Magento\Catalog\Model\Product::isAvailable * @covers \Magento\Catalog\Model\Product::isInStock */ public function testIsSalable() { $this->_model = $this->productRepository->get('simple'); // fixture $this->assertTrue((bool) $this->_model->isSalable()); $this->assertTrue((bool) $this->_model->isSaleable()); $this->assertTrue((bool) $this->_model->isAvailable()); $this->assertTrue($this->_model->isInStock()); $this->_model->setStatus(0); $this->assertFalse((bool) $this->_model->isSalable()); $this->assertFalse((bool) $this->_model->isSaleable()); $this->assertFalse((bool) $this->_model->isAvailable()); $this->assertFalse($this->_model->isInStock()); }
/** * Define if selection is selected * * @param \Magento\Catalog\Model\Product $selection * @return bool */ public function isSelected($selection) { $selectedOptions = $this->_getSelectedOptions(); if (is_numeric($selectedOptions)) { return $selection->getSelectionId() == $selectedOptions; } elseif (is_array($selectedOptions) && !empty($selectedOptions)) { return in_array($selection->getSelectionId(), $selectedOptions); } elseif ($selectedOptions == 'None') { return false; } else { return $selection->getIsDefault() && $selection->isSaleable(); } }
/** * {@inheritdoc} */ public function isSaleable() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'isSaleable'); if (!$pluginInfo) { return parent::isSaleable(); } else { return $this->___callPlugins('isSaleable', func_get_args(), $pluginInfo); } }