If you ever had issues with products disappearing from collections when they shouldn’t be, here’s one of the possible reasons:
method, which calls
on EVERY product collection, which has some nasty consequences.
For example, if you have configured System > Configuration > Inventory > Stock Options > Display Out of Stock Products to No, then all the out of stock products will not show up in ANY product collection, because $collection->addPriceData() inner joins with price index table, which doesn’t have entries for products not shown on the frontend (Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection::_productLimitationJoinPrice)
Anyways, I hope this saved you few minutes (hours) of debugging… I will update this post when or if I’ll find an acceptable solution.
UPDATE: Got a clarification from senior Magento developer: This is an intended behavior.
All the product collections, when not in admin, will be forced to hide products out of stock if this is configured.
I don’t like it, and don’t think that should be the case, but I guess that’s life.