X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Modifying the Quick Search to perform an exact search (https://forum.x-cart.com/showthread.php?t=76168)

chamberinternet 04-11-2018 01:44 AM

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

cflsystems 04-11-2018 05:07 AM

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

chamberinternet 04-11-2018 06:57 AM

Re: Modifying the Quick Search to perform an exact search
 
Thanks Steve

That appears to be working :)


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

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