You are here:  » Is numMerchants correctly computed?


Is numMerchants correctly computed?

Submitted by keymaster on Fri, 2006-08-18 10:06 in

Hi David,

The line in search.php for the "merchants" case:

$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE ".$where." GROUP BY name";

would seem to always return numMerchants of 1, since the preceding where clause stored in $where is:

$where = " ".$parts[0]."='".database_safe($parts[1])."' ";

which restricts the rows to only those where merchant= the_merchant_selected.

So, on the searchresults.php page, when you get a listing for all products by that merchant, the prices will say "More information".

But, shouldn't it really say "Compare Prices", since when you click to go to the product.php page, all the merchants are there with their prices (not only the merchant selected)?

Am I mistaken?

Submitted by support on Fri, 2006-08-18 10:36

Hi There,

When doing a "merchant:" search, numMerchants will always be 1; which is why the "More Information" link is used because at that point the script does not know how many other merchants there are (if any) because it was merchant name, not product name that was used in the query.

In order to show "Compare Prices", it would be necessary to search every product in the result set independantly to get the merchant count, which would be far too slow.

Hope this makes sense!
Cheers,
David.