For my module I need to create a custom productCollection built with various addAttributeToFilter modifiers. However, I have no idea how to get such a collection into a product list like the default magento one. So basicly I'd like to create a pre-filtered product list, could anyone give me some advice on how to start such a thing?
EDIT: Just to clarify, I can make the collection, just not show it like the default product list.
After hours of struggling I found a solution: I overrided Mage_Catalog_Block_Product_List and made my own _getProductCollection with:
$collection = parent::_getProductCollection();
$collection->addAttributeToFilter('attribute', array('operator' => 'value'));
/* more filters go here */
$this->_productCollection = $collection;
return $this->_productCollection;
This seemed to be the only way to get the original product list working without any errors or category problems.
With thanks to Guerra!!
use this in list.phtml:
$_productCollection->clear()
->addAttributeToFilter('attribute_set_id', array('eq' => 63))
->load();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With