I created a custom form that search for specific product attribute my form look like this
$location = $this->getRequest()->getParam('location');
$specialization = $this->getRequest()->getParam('specialization');
$name = $this->getRequest()->getParam('name');
$attrSetName = "Group Deal";
$attributeSetId = Mage::getModel('eav/entity_attribute_set')
->load($attrSetName, 'attribute_set_name')
->getAttributeSetId();
$_productCollection=$this->getLoadedProductCollection();
$_productCollection->clear()
->addFieldToFilter('attribute_set_id', $attributeSetId)
->addAttributeToFilter('type_id', array('eq' => 'virtual'));
//Default Count//
$count = $_productCollection->getSize();
<?php if(!empty($location)): ?>
<?php $_productCollection->clear()->addAttributeToFilter('contact_city', array('like' =>$location.'%' )); ?>
<?php endif;?>
<?php if($specialization>0): ?>
<?php $_productCollection->clear()->addAttributeToFilter('doctor_specialization',$specialization);?>
<?php endif;?>
<?php if(!empty($name)): ?>
<?php $_productCollection->clear()->addAttributeToFilter('name', array('like' =>'%'.$name.'%' )); ?>
<?php endif;?>
The above line of code is how i return my results. How ever when i search with 2 search parameters like name and location im not getting accurate results, Is there any way to improve the search query? Any help would be appreciated very much.