cancel
Showing results for 
Search instead for 
Did you mean: 

Attribute Indexing ignores custom source model options

0 Kudos

Attribute Indexing ignores custom source model options

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...

11 Comments
JosephMaxwell
Certification Board Member

Hello,

 

I just ran into this issue as well. Here is @c3media_robert's fix that I have implemented into an easy-to-install package:

 

https://github.com/SwiftOtter/AttributeIndexFix

 

Joseph