You are here:  » Additional case on search.php


Additional case on search.php

Submitted by marco.saiu on Fri, 2018-02-02 08:29 in

Hi David,

i can add other case: in search.php (not sitesearch) i try add others case but with this change search not search.

case "tutte le offerte" || "Tutte le Offerte" || "TUTTE LE OFFERTE":
$where = "search_name LIKE '%'";
$sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
$orderBySelection = $orderByDefault;
break;

I add this in search.php next the line 238 but not work.

Thanks,
Marco Saiu

Submitted by support on Fri, 2018-02-02 08:53

Hi Marco,

You can link to all products using the bw: (begins with) operator - with nothing after the ":" it returns all products; for example...

<a href='<?php print $config_baseHREF?>search.php?q=bw:'>Tutte le Offerte</a>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco.saiu on Fri, 2018-02-02 09:07

Hi David,

is an example i have more additional bypass for example:

case "tutti gli sconti" || "Tutti gli Sconti" || "TUTTI GLI SCONTI":
$where = "search_name LIKE '%' AND rebate <> ''";
$sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
$orderBySelection = $orderByDefault;

if $q equal to this make this query and not default query.

Thanks,
Marco Saiu

Submitted by support on Fri, 2018-02-02 09:11

Hi Marco,

Sure - you can insert the new case just before the default case, so where you have the following code at line 239:

      default:

...REPLACE with:

      case "tutti gli sconti":
      case "Tutti gli Sconti":
      case "TUTTI GLI SCONTI":
        $where = "search_name LIKE '%' AND rebate <> ''";
        $sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
        $orderBySelection = $orderByDefault;
      default:

Or rather than the repeated case statements, to catch all cases you could strtolower() $parts[0] in the switch() statement so where you have the following code at line 99:

    switch($parts[0])

...and REPLACE with:

    switch(strtolower($parts[0]))

And then instead of the above replacement, just:

      case "tutti gli sconti":
        $where = "search_name LIKE '%' AND rebate <> ''";
        $sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
        $orderBySelection = $orderByDefault;
      default:

Cheers,
David.
--
PriceTapestry.com