Product Collections: Get ALL products even though “Show products that are out of stock” set to NO?

magento.stackexchange https://magento.stackexchange.com/questions/6336

سؤال

I’d like to list products using Product Collections that list ALL products regardless is_salable or in_stock are false. Is there a way I can disable all is_salable or in_stock checks for Mage::getResourceModel('catalog/product_collection') ?

Getting the product collection is done using:

$selections = Mage::getResourceModel('catalog/product_collection')
  ->addAttributeToSelect('*')
  ->addMinimalPrice()
  ->addFinalPrice()
  ->addTaxPercents()
  ->addStoreFilter()
  ->addIdFilter($selection_ids, false)
  ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);

  $selections->load();

but because "Show products that are out of stock" ist set to NO it automatically wipes all products that are not in stock.

Is there a way to bypass the "show_out_of_stock" check? Thanks for any assistance!

هل كانت مفيدة؟

المحلول

Very weird. Can't really tell why, but removing ->addFinalPrice() fixed the issue. Obviously addFinalPrice() removes all products that aren't saleable/in stock.

نصائح أخرى

With Magento 1.8, comment addMinimalPrice and addFinalPrice in *Mage_Catalog_Model_Layer::prepareProductCollection()* to show out of stock products with Show products that are out of stock set to NO.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top