/** * @magentoDataFixture Mage/Catalog/_files/product_simple.php */ public function testIsSalable() { $product = new Mage_Catalog_Model_Product(); $this->assertTrue($this->_model->isSalable($product)); $product->load(1); // fixture $this->assertTrue((bool) $this->_model->isSalable($product)); }
public function isSalable($product = null) { $amountOptions = $this->getProduct($product)->getPriceModel()->getAmountOptions($product); $open = $this->getProduct($product)->getAwGcAllowOpenAmount(); if (!$open && !$amountOptions) { return false; } return parent::isSalable($product); }
/** * Check if product is available for sale * * @param Mage_Catalog_Model_Product $product * * @return bool */ public function isSalable($product = null) { $salable = parent::isSalable($product); if ($salable) { foreach ($this->getAssociatedProducts($product) as $associatedProduct) { $salable = $salable && $associatedProduct->isSalable(); } } return $salable; }
/** * Check is product available for sale * * @return bool */ public function isSalable() { $salable = parent::isSalable(); if (!is_null($salable)) { return $salable; } $salable = false; foreach ($this->getAssociatedProducts() as $product) { $salable = $salable || $product->isSalable(); } return $salable; }
/** * Check is product available for sale * * @return bool */ public function isSalable($product = null) { $salable = parent::isSalable($product); if ($salable !== false) { $salable = false; foreach ($this->getUsedProducts(null, $product) as $child) { if ($child->isSalable()) { $salable = true; break; } } } return $salable; }
/** * Checking if we can sale this bundle * * @param Mage_Catalog_Model_Product $product * @return bool */ public function isSalable($product = null) { $salable = parent::isSalable($product); if (!is_null($salable)) { return $salable; } $optionCollection = $this->getOptionsCollection($product); if (!count($optionCollection->getItems())) { return false; } $requiredOptionIds = array(); foreach ($optionCollection->getItems() as $option) { if ($option->getRequired()) { $requiredOptionIds[$option->getId()] = 0; } } $selectionCollection = $this->getSelectionsCollection($optionCollection->getAllIds(), $product); if (!count($selectionCollection->getItems())) { return false; } $salableSelectionCount = 0; foreach ($selectionCollection as $selection) { if ($selection->isSalable()) { $requiredOptionIds[$selection->getOptionId()] = 1; $salableSelectionCount++; } } return array_sum($requiredOptionIds) == count($requiredOptionIds) && $salableSelectionCount; }
/** * Check is product available for sale * * @param Mage_Catalog_Model_Product $product * @return bool */ public function isSalable($product) { $salable = parent::isSalable($product); if ($salable !== false) { $salable = false; if (!is_null($product)) { $this->setStoreFilter($product->getStoreId(), $product); } foreach ($this->getUsedProducts($product) as $child) { if ($child->isSalable()) { $salable = true; break; } } } return $salable; }
/** * Check is product available for sale * * @return bool */ public function isSalable($product = null) { $salable = parent::isSalable($product); if (!is_null($salable)) { return $salable; } $salable = false; foreach ($this->getUsedProducts(null, $product) as $child) { $salable = $salable || $child->isSalable(); } return $salable; }
/** * Check is product available for sale * * @param Mage_Catalog_Model_Product $product * @return bool */ public function isSalable($product = null) { $salable = parent::isSalable($product); if ($salable !== false) { $salable = false; if (!is_null($product)) { $this->setStoreFilter($product->getStoreId(), $product); } if (!Mage::app()->getStore()->isAdmin() && $product) { $collection = $this->getUsedProductCollection($product)->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setPageSize(1); if ($collection->getFirstItem()->getId()) { $salable = true; } } else { foreach ($this->getUsedProducts(null, $product) as $child) { if ($child->isSalable()) { $salable = true; break; } } } } return $salable; }
/** * Checking if we can sale this bundle * * @param Mage_Catalog_Model_Product $product * @return bool */ public function isSalable($product = null) { $salable = parent::isSalable($product); /* benz001 * Instead of checking for null we should evalualte the result if it exists * if (!is_null($salable)) { return $salable; } */ if (!is_null($salable)) { if (!$salable) { return false; } } $optionCollection = $this->getOptionsCollection($product); if (!count($optionCollection->getItems())) { return false; } $requiredOptionIds = array(); foreach ($optionCollection->getItems() as $option) { if ($option->getRequired()) { $requiredOptionIds[$option->getId()] = 0; } } $selectionCollection = $this->getSelectionsCollection($optionCollection->getAllIds(), $product); if (!count($selectionCollection->getItems())) { return false; } $salableSelectionCount = 0; //benz001 in this loop we check against the required quantities for each option as well foreach ($selectionCollection as $selection) { if ($selection->isSalable()) { if ($selection->getSelectionQty() <= $selection->getStockItem()->getQty()) { $requiredOptionIds[$selection->getOptionId()] = 1; $salableSelectionCount++; } } } return array_sum($requiredOptionIds) == count($requiredOptionIds) && $salableSelectionCount; }
public function isSalable($product = null) { if (!$product) { return false; } $prod = Mage::getModel('catalog/product')->load($product->getId()); if ($prod->getAttributeText('wts_gc_pregenerate') != 'Yes') { return parent::isSalable($product); } $collection = Mage::getModel('giftcards/pregenerated')->getCollection()->addFieldToFilter('product_id', $product->getId())->addFieldToFilter('card_status', 1); if (!count($collection)) { return false; } return true; }