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
Not applicable
Status changed to: Investigating
 
Not applicable

Comment from Zifius, posted on GitHub Nov 24, 2013

This is exactly the issue I've faced about a year ago and solved it in a similar (albeit a bit dirtier approach) but this is something bothers me still. Thank you for the good description of the issue

I wonder if this can be solved even more elegantly without changing core files by implementing own indexer or the indexing should be improved in the core. @IvanChepurnyi can you advise please?

Not applicable

Comment from Zifius, posted on GitHub Dec 12, 2013

@simonspoerri found my SO thread regarding the issue http://stackoverflow.com/questions/7597448/multi-select-filter-in-layered-navigation/

@mage2-team any insight on this? Thank you

Not applicable

Comment from simonspoerri, posted on GitHub Dec 12, 2013

@Zifius, sorry i didn't attach the following link, http://www.magestore.com/magento/multi-select-filter-in-layered-navigation.html/, upon which my suggestion is based. Thanks for your help on this!

Not applicable

Comment from Zifius, posted on GitHub Dec 12, 2013

@simonspoerri looks like that site just aggregated my answer on SO which is the origin

Not applicable

Comment from kokoc, posted on GitHub Feb 03, 2015

@simonspoerri Thank you for reporting the issue and sorry for so biiiiig delay.

Internal reference: MAGETWO-33570 We will fix the problem and get back to you once we have the working code.

Not applicable

Comment from LittleBigDev, posted on GitHub Oct 29, 2015

Hello @kokoc, did you plan a similar fix for Magento 1 ? I'm currently on EE 1.14 and iI have this bug too (class Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source). If my question should be asked somewhere else, please tell me Smiley Happy

M1 Certified

Since this was moved from Github there has been no update. Any progress on this feature that is actually a bug?

New Member

Don't mind me. Posting here just to keep following this issue.

M1 Certified

Given my above comment, I'm adding information to the github ticket. I've posted a possible fix, that with a bit of DI overriding could be used to patch this while we wait for Magento to do so:

 

https://github.com/magento/magento2/issues/417