You are here:  » Price Comparison


Price Comparison

Submitted by dflsports on Fri, 2006-03-31 04:33 in

I am trying to figure out how the price comparison works. I see the products on the main demo page has the comparison feature. How does this work? Does it match product names that are exact?

Can this be done for all products on the individual product pages?

Thanks!

Submitted by support on Fri, 2006-03-31 08:07

Hi Don,

I think you're looking at features of the new distribution which I released a couple of days ago. You can download the new version now...

Submitted by dflsports on Fri, 2006-03-31 19:15

Yes, I have the new version. I am looking at it now, just trying to figure out how the price comparison works. I'm a little slow :)

Submitted by support on Fri, 2006-03-31 19:19

It's basically a SELECT from the database using a GROUP BY clause on the product name field - that's it. So yes, all it does it pick products from the database with identical names in order to perform the comparison.

The critical line of code is this (in search.php):

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

So it groups by "name", and from that group selects the minimum price etc. If you're interested; the docs for this particular style of query are here:

http://dev.mysql.com/doc/refman/4.1/en/group-by-functions.html

Cheers,
David.

Submitted by dflsports on Sat, 2006-04-01 01:33

Thanks David, I appreciate the information.