I have created an observer that manipulates the advanced search result of Magento. For this, I've used the controller_action_layout_render_before_catalogsearch_advanced_result observer.

I'm using an "dummy" attribute called "brand". This attribute doesn't accually contain something, but is just there so that the user can input a value in the normal magento forms.

Now my problem is that I can not seem to remove this dummy attribute. I've tried removeAttributeFromFilter() (and removeFieldFromFilter()) but it does not seem to disappear.

I cannot just reset the WHERE statement, because all other attributes do need to function like normal.

The observer:

class Jeroen_SearchFilter_Model_Observers_Searchresults
      function manipulateSQL( $event ){
         if(!Mage::app()->getRequest()->getOriginalPathInfo() == "/catalogsearch/advanced/result/";){ 
            //double check if this we're really using advanced search

         $block = Mage::app()->getLayout()->getBlock('search_result_list');

             $collection = $block->getLoadedProductCollection();
             $searchFilterTable = Mage::getSingleton('core/resource')->getTableName('searchFilter/searchtable');
             $collection->getSelect()->join(array("searchfilter" => $searchFilterTable), "e.entity_id = searchfilter.product_id" );
             $collection->getSelect()->where("searchfilter.brandAttributeId = 'mybrand'");


Does anyone know how to remove the brand attribute from the collection?

2 Answers 2


No, you have to construct a new query. Once you hit the DB with a query with conditions, you can't just remove a condition and have new data, you have to construct a new query.

Afaik standard Magento does not have any methods to explicitely remove filters (besides clear(), which resets all filters and unloads the collection).

Check here for more information

  • This is what I have now, plus array and range support (from, to price for example).
    – Jeroen
    Commented Mar 29, 2016 at 7:52

To my knowledge the only way is to edit the where part and remove the part where the condition is set on the attribute you want to remove:

$where = $collection->getSelect()->getPart(Zend_Db_Select::WHERE);
foreach ($where as $key => $condition)
    // You may have to adapt this condition depending on the situation
    if (strpos("brand",$condition) !== false)
$collection->getSelect()->setPart(Zend_Db_Select::WHERE, $where);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.