You are here:  » Exact title match result

Support Forum



Exact title match result

Submitted by mikecdprice on Sun, 2011-02-20 18:23 in

Hello,

I am looking for a way to tell the script to only display the results of the "EXACT" title only.

So if the product search:

baby easter ears

only exact match results would appear:

(1) found.

baby easter ears

How would I do that. Right now it brings up other variations.

Thank you

Submitted by support on Mon, 2011-02-21 09:02

Hi Mike,

All you need to do is replace the default search handler with a much more basic name = query version. To do this, look for the following section in search.php:

      default:
       ...83 lines...
        break;

...and REPLACE with:

      default:
        $where = "name = '".database_safe($parts[0])."'";
        $sql = "SELECT SQL_CALC_FOUND_ROWS * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY name";
        $orderBySelection = $orderByDefault;
        break;

That will perform an exact match only (so continuing your example would NOT match "baby easter ears yellow". If you want to still match the exact string but allow other words in the title as well, use an alternative where clause as follows:

        $where = "name LIKE '%".database_safe($parts[0])."%'";

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Mon, 2011-02-21 20:20

wonderful thank you

Submitted by mikecdprice on Tue, 2011-02-22 04:37

Hello,

I tried edit this exactly as above and I cannot get it to display any results. As with the above edit it says no results found on all results.

Any ideas? I am using the most current version.

Thank you,
Michael

Submitted by support on Tue, 2011-02-22 09:22

Hi Michael,

Could you email me your modified search.php and I'll check it out for you...

Cheers,
David.
--
PriceTapestry.com