X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   Plural Searches (https://forum.x-cart.com/showthread.php?t=49232)

toolauthority 08-19-2009 10:26 AM

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);
    }



Jayk 08-19-2009 10:48 AM

Re: Plural Searches
 
Thanks for the tip.

Jason

bigredseo 08-19-2009 12:28 PM

Re: Plural Searches
 
I like it! Looks like it would do the trick on just about anything.


All times are GMT -8. The time now is 04:04 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.