Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Plural Searches

 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #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

The following user thanks toolauthority for this useful post:
Jayk (08-20-2009)
  #2  
Old 08-19-2009, 10:48 AM
  Jayk's Avatar 
Jayk Jayk is offline
 

eXpert
  
Join Date: Nov 2003
Location: Calgary, Alberta, Canada
Posts: 333
 

Default Re: Plural Searches

Thanks for the tip.

Jason
__________________
X-Cart Gold 4.4.3
Blog: www.flashinthepan.ca
Reply With Quote
  #3  
Old 08-19-2009, 12:28 PM
  bigredseo's Avatar 
bigredseo bigredseo is offline
 

X-Man
  
Join Date: Oct 2002
Location: Omaha, NE, USA
Posts: 2,364
 

Default Re: Plural Searches

I like it! Looks like it would do the trick on just about anything.
__________________
Conor Treacy - Big Red SEO - @bigredseo
Search Engine Optimization & Internet Marketing - We Bring Your Website Out Of Hiding!
If you can't be found on Google, Bing or Yahoo, you pretty much don't exist on the Internet.
Omaha SEO Office with National & Local SEO Services
Hourly Consulting - great for SEO Disaster Recovery, Audits and DIY Guidance
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020