1

I'd like to load products by IDs, but ignore the product visibility. So when loading a product collection I'd like to even have products in the collection that have visibility "Search".

On a related note: I am using a custom Catalog Block extending Mage_Catalog_Block_Product_List so I can get the product list by calling

Mage::app()->getLayout()->createBlock('catalog/product_list_xyz')->setTemplate('catalog/product/list.phtml')

Inside my custom catalog type block I'm using Mage::getModel('catalog/layer')->prepareProductCollection($collection); Is there any way to "reset" the visibility filter?

1
  • There is no way to reset visibility filter on collection class Sep 30 '15 at 11:43
3

This question is related to collection - Load visible and invisible products at once.

To reset the visiblity filter, try this:

$_productCollection->setVisibility(null);

You can change the filter using the following code:

$_productCollection->setVisibility(array(
    Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
    Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
    Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
);
2
  • Using $_productCollection->setVisibility(null); did the trick. Thank you!
    – oschloebe
    Sep 30 '15 at 18:01
  • I think it is only for magento1. Not working in magento2. Please give example for mangento2 as well. Nov 1 '17 at 20:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.