Magento – Magento Advance Search Exact Result For Particular Attribute Value

advanced-search

I have a magento store where i have used magento advance search on home page. Works fine. In search form there is an attribute (caliber) which is actually a text type attribute but i m showing this attribute as dropdown in fronted (Used custom query to fetch the attribute value of all the product). It's also working fine. I want to show the exact result with this attribute value. Example : if caliber value is 9mm then only this product should show but it rather shows other products whose attribute value is 7mmX39mm since this has 9mm as well.
I have changed search type mode from LIKE to FULLTEXT but both of mode are giving same result for me. Any help will be highly appreciated.

Best Answer

I have modified prepareCondition function in advanced.php page

app/code/local/Mage/CatalogSearch/Model/Resource/Advanced.php

Replaced below code

if (strlen($value) > 0) {
if (in_array($attribute->getBackendType(), array('varchar', 'text', 'static'))) {
$condition = array('like' => '%' . $value . '%'); // text search
} else {
$condition = $value;
}
}

BY

if (strlen($value) > 0) {
$condition = $value;
}

I got desire output.Thanks

Related Topic