我想按 ID 加载产品,但忽略产品可见性。因此,在加载产品集合时,我什至希望集合中的产品具有“搜索”可见性。

相关说明:我正在使用自定义目录块扩展 Mage_Catalog_Block_Product_List 所以我可以通过致电获取产品列表

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

在我正在使用的自定义目录类型块内 Mage::getModel('catalog/layer')->prepareProductCollection($collection); 有什么方法可以“重置”可见性过滤器吗?

有帮助吗?

解决方案

这个问题与 系列 - 立即加载可见和不可见的产品.

要重置可见性过滤器,请尝试以下操作:

$_productCollection->setVisibility(null);

您可以使用以下代码更改过滤器:

$_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
);
许可以下: CC-BY-SA归因
scroll top