I have a custom product collection.
$collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('entity_id', array('in' => $ids));
The products have only some attributes set like: entity_id, entity_type_id, attribute_set_id, type_id, sku, created_at, updated_at, is_salable, stock_item (is an object). Also for more attributes I can add the method
->addAttributeToSelect(array('name'))
I noticed, that if I don't add the status field to the collection using the method above, then if I want to see if the products from the collection can be bought using isSaleable it will return true because in Mage_Catalog_Model_Product
public function getStatus()
{
if (is_null($this->_getData('status'))) {
$this->setData('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
} ...
and in Mage_Catalog_Model_Product_Type_Abstract
public function isSalable($product = null)
{
$salable = $this->getProduct($product)->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED; ...
Is this a bug? Do I always need to add the status field to the collection? Does anyone know of any other fields you have to add to the collections because of Magento's logic? Why didn't they force the status to be added in a core observer on before collection load?