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

Modifying the Quick Search to perform an exact search
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 04-11-2018, 01:44 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,447
 

Default Modifying the Quick Search to perform an exact search

On a store running XC 4.6.3 I need to modify the quick search so that an exact word/phrase match is found..

The code I have at the moment is as follows:


Code:
<form method="post" action="search.php" name="productsearchform"> <input type="hidden" name="simple_search" value="Y" /> <input type="hidden" name="mode" value="search" /> <input type="hidden" name="posted_data[by_title]" value="Y" /> <input type="hidden" name="posted_data[search_in_subcategories]" value="Y" /> <input type="hidden" name="posted_data[by_descr]" value="N" /> <input type="hidden" name="posted_data[including]" value="all" /> <input type="hidden" name="posted_data[extra_fields][1]" value="Y" /> <input type="hidden" name="posted_data[by_sku]" value="Y" /> <input type="text" name="posted_data[substring]" class="text default-value" value="Keyword Search" /> <input class="image-button btn-search" type="image" src="/store/skin/common_files/images/spacer.gif" alt="" />

I tried changing the parameter for posted_data[including] to "phrase" but that does seem to have resolved it ...

Can anyone help?

Cheers

Shafiq :sK
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #2  
Old 04-11-2018, 05:07 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,097
 

Default Re: Modifying the Quick Search to perform an exact search

This parameter takes "all, any, phrase". However at the end they all perform the search for "like" not exact match.
If you want to do exact match you need to modify the /include/search.php and change the query from

PHP Code:
$condition[] = $sql_tbl['products_lng_current'] . '.' $ssf ' LIKE \'%' $data['substring'] . '%\''

to

PHP Code:
$condition[] = $sql_tbl['products_lng_current'] . '.' $ssf ' = \'' $data['substring'] . '\''

Just a sample code - yours may be different
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 2 users thank cflsystems for this useful post:
chamberinternet (04-11-2018), PhilJ (04-11-2018)
  #3  
Old 04-11-2018, 06:57 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,447
 

Default Re: Modifying the Quick Search to perform an exact search

Thanks Steve

That appears to be working
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:46 AM.

   

 
X-Cart forums © 2001-2018