Feature request from simonspoerri, posted on GitHub Nov 21, 2013
Currently The indexing of Attribute Values used for the product filters in the category overview only index multiselect attributes that use attribute options. If a custom source model is specified the values are not indexed and thus are not taken into account when filtering products.
To fix the issue in my case I created an interface which all Source Models that should be taken into account while indexing should implement. For Attributes implementing this interface not only attribute options from the DB are indexed but also all options provided by the source model.
the class in question is Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source . I've overridden the _prepareMultiselectIndex Method and added the following snippet after the attribute options are loaded from 'eav/attribute_option'
foreach($attrIds as $attributeId) {
$attributeModel = Mage::getModel(Mage_Eav_Model_Entity::DEFAULT_ATTRIBUTE_MODEL)->load($attributeId);
if($attributeModel->getSource() instanceof MyNS_MyModule_Model_Product_Attribute_Source_Interface) {
$sourceModelOptions = $attributeModel->getSource()->getAllOptions();
foreach($sourceModelOptions as $o) {
$options[$attributeId][$o["value"]] = true;
}
}
}
Maybe I'm misusing some principles here but I really think custom source model based multiselect attributes should be filterable as well, thus they need to be indexed...