0
votes

Magento: Filter based on simple product level attribute.

I have created a custom attribute namly 'color_range' from Magento admin. This attribute is in simple product level (so, not available in configurables.) and also set as filterable. Here, I am facing an issue with product filtering based on this attribute. Configurable products were not returned in the collection even though there are associated products (simple) with provided value. Is this expected behaviour ? Can anybody please help? My code follows:

$collection->addAttributeToFilter('color_range', array('eq' => 1788 ));

Thanks! Iqbal.

1
the simple products associated with the configurable products are NOT VISIBLE on frontend. - Manashvi Birla
@Manashvibirla I don't need the simple products in the list. I want Configurable in the result. Here the issue is that the filterable attribute is in the simple product level. Thanks! - iqbalmp
if you haven't configured the attribute for configurable products, then the configurable products will not be listed in the collection - Manashvi Birla
@Manashvibirla The above provided attribute (color_range) is a configurable attribute. Eg:- Configurable Product C1, associated products: A1(color_range - a),B(color_range-b),C(color_range-c). - iqbalmp

1 Answers

0
votes

Mapping( Join on table) is done between attribute EAV table with Catalog flat table( assuming catalog flat is on). Relation of Simple to configurable is in super links table which is not considered for collection.

So unless a configurable product has that attribute it will not be displayed on collection.

You need to modify code to handle this.