Thread: Plural Searches
View Single Post
  #1  
Old 08-19-2009, 10:26 AM
  toolauthority's Avatar 
toolauthority toolauthority is offline
 

Advanced Member
  
Join Date: Jan 2009
Location: Grand Rapids, MI
Posts: 92
 

Default Plural Searches

Just though I would share with everyone what I just did to fix plurals on our site.

ex. some body searches for dewalt batteries, but none of them show up because they say battery not batteries.

It's not super smart; but it's short, simple and to the point.

Edit the include/search.php file before the line
Code:
foreach ($search_string_fields as $ssf) {
(around line 330)

PHP Code:
// kee kyle eadie
// strip out plurals as best as we can
if (!empty($search_words) && is_array($search_words)) {
    foreach(
$search_words as $swid => $word) {
        if (
substr($word,-3) == "ies"$search_words[$swid] = substr($word,0,-3);
        else if (
substr($word,-2) == "es"$search_words[$swid] = substr($word,0,-2);
        else if (
substr($word,-1) == "s"$search_words[$swid] = substr($word,0,-1);
    }

__________________
x-cart 4.2.0 | centos 5.2 | php 5.2.6 | mysqld 5.0.45-log
Reply With Quote