The Magento platform is great especially for small to medium business. It’s a bit of a monster to learn but it offers a lot out of the box. Having said this there are a few things that need to be tweaked. This post is about the Magento search function which to be honest sucks, why?
I work for a company that sell outdoor furniture and one of our product ranges are parasols. We sell wooden, aluminium and high end teak ones. If you don’t modify the search function and a customer does a search for lets say ‘wooden parasol’ they would be presented with hundreds of results with a lot of the results not having anything to do with parasols. This is because it will look for every instance of the word ‘wooden’ and every instance of the word ‘parasol’. Your customer is most likely not going to want to have to scroll through pages and pages of results trying to find that elusive parasol and will go somewhere else.
How do you improve your search query results? Fire up your FTP client and get out your favourite text editor it’s time to get stuck in.
That was a bit over dramatic it actually quite simple we just need to modify two files.
Find ‘form.mini.phtml’ in
Between the form tags place these two hidden form fields.
<input type="hidden" name="order" value="relevance">
<input type="hidden" name="dir" value="desc">
Then you need to make a copy of
and place it in
Depending how much work you have already done on your site you might need to create this directory structure.
Warning! It is important to create this second ‘local’ directory never edit files within the ‘core’ directory why? Well that is one for another post.
In ‘Fulltext.php’ find the line
$likeCond = '(' . join(' OR ', $like) . ')';
and change to
$likeCond = '(' . join(' AND ', $like) . ')';
Then find the line
$where .= ($where ? ' OR ' : '') . $likeCond;
And change it to
$where .= ($where ? ' AND ' : '') . $likeCond;
You can see easily what’s being changed here so we are saying instead of searching for
Word(1) OR Word(2) = Every single instance of each word
We are changing it to say
Word(1) AND Word(2) = Every instance of these two (or more) being used together
Result! Much better search results for your customers so they can find the product they want faster.
Credit to Markus Tenghamn @ markustenghamn.com for this useful bit of code.