Submitted by FirstByte on Mon, 2009-06-01 22:03 in Price Tapestry
Hi David,
I was playing was playing around with the full product list (http://www.pricetapestry.com/node/2646) How would i go about change the SQL qeury to only display those products that are compared? Is this easy to do?
Sure - you can modify the bw: handler to only display products where numMerchants is > 1. To do this, look for the following block of code, beginning at line 54 in search.php
case "bw":
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%' GROUP BY name";
$sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%'";
$orderBySelection = $orderByDefault;
break;
...and REPLACE this with:
case "bw":
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%' AND numMerchants > 1 GROUP BY name";
$sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%' AND numMerchants > 1";
$orderBySelection = $orderByDefault;
break;
Hi Rod,
Sure - you can modify the bw: handler to only display products where numMerchants is > 1. To do this, look for the following block of code, beginning at line 54 in search.php
case "bw":
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%' GROUP BY name";
$sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%'";
$orderBySelection = $orderByDefault;
break;
...and REPLACE this with:
case "bw":
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%' AND numMerchants > 1 GROUP BY name";
$sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '".database_safe($parts[1])."%' AND numMerchants > 1";
$orderBySelection = $orderByDefault;
break;
Cheers,
David.