where does is_salable come from?

isAvailable() looks like this:

public function isAvailable()
{
    return $this->getTypeInstance(true)->isSalable($this)
        || Mage::helper('catalog/product')->getSkipSaleableCheck();
}

This means that the result of the method depends on the product type.
Each product type has a isSalable() method:

  • Mage_Catalog_Model_Product_Type_Grouped::isSalable() - for grouped products
  • Mage_Catalog_Model_Product_Type_Configurable::isSalable() - for configurable products
  • Mage_Catalog_Model_Product_Type_Abstract::isSalable() - for the rest of product types since all the product types extend Mage_Catalog_Model_Product_Type_Abstract.
    I think that the call $this->getTypeInstance(true) confuses you. The method getTypeInstance() does not return an instance of the product model, but an instance of a product type.

[EDIT]
For a simple product this is called Mage_Catalog_Model_Product_Type_Grouped::isSalable(). This method checks if the product is enabled. If not then false is returned. If it's enabled, then it checks if it has a property is_salable that can be set by one of your observers.
If it does not have such a property then it checks if the product type instance $this->isComposite(). If it is then it's not salable.
For configurable products it checks if the conditions above are met and if there is a simple product associated to the configurable one that is salable (Again with the conditions above)
The same is done for the grouped product but in a different way.

In conclusion is_salable doesn't have to exist. But just in case you have an observer that sets that property it's taken into consideration when checking if the product can be sold.
Here is an example from the core: The method Mage_CatalogInventory_Model_Stock_Status::assignProduct() cals $product->setIsSalable()
Same goes for Mage_CatalogInventory_Model_Stock_Status::addStockStatusToProducts.
The last one is called by the event catalog_product_collection_load_after.


if is Saleable returns false, Reindexing can also have issue reindex the data

Tags:

Core

Catalog