I’ve come a bit further on this. I wrote a Model extension for the Catalog_Layer_Model, adding my attribute that needs to be filtered there.
class Sitesquad_Catalog_Model_Layer extends Mage_Catalog_Model_Layer
public function prepareProductCollection($collection)
->addAttributeToFilter('hero','1') // <------ forcing display of 'hero' products only
I found I needed to add it in the model, because otherwise the counts in the layered navigation would not update.
The problem now is that this filter is always applied, which is something I do not want. I need to make it so that it is only apply under certain conditions, e.g. for specific categories and only if not filtered by color.
Now because I’m doing this early in the Model code, any other filters have not yet been added by the Layer Block. So I can’t test in the model what else might be filtered by, or which category I’m currently in.
On the other hand, I cannot add the filter late in the code, because the product collection will have already been fetched and the filter has no effect.
I’m looking for a better place to intervene in the filtering - as late as possible so that I can check on conditions.