I want to apply some custom filter on $collection = Mage::getResourceModel('catalogsearch/fulltext_collection')
search collection.
For this I have created a custom module and override Mage_CatalogSearch_Model_Layer
getProductCollection
function.
How to apply ->addAttributeToFilter('custom_attribute',array('in' => $array))
?
When I try to apply above filter to catalogsearch collection then it returns error :
Column not found: 1054 Unknown column 'e.custom_attribute' in 'where clause', query was: SELECT FLOOR((ROUND((e.min_price) * 1, 2)) / 100000) + 1 AS `range`, COUNT(*) AS `count` FROM `catalog_product_index_price` AS `e`
INNER JOIN `catalogsearch_result` AS `search_result` ON search_result.product_id=e.entity_id AND search_result.query_id='33'
INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id = '2' WHERE 1=1 AND ( final_price >= "10000" AND final_price <= "145268" ) AND (e.custom_attribute IN(190, 1247, 2862, 2863, 2864)) AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_price IS NOT NULL) GROUP BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100000) + 1 ORDER BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100000) + 1 ASC
->addAttributeToFilter('custom_attribute',array('in' => $array))
it returns unknown column e.custom_attribute
error.
How to resolve this error?
Best Answer
Use above to filter,
Also you can try