You are here:  » Product Grouping

Support Forum



Product Grouping

Submitted by knight01 on Thu, 2007-06-28 06:00 in

When a user clicks on the link Brand it shows all the the brands on the site. When they choose a brand, they see all of the products within that brand.

So far, so good.

But if there are multiple merchants with the same product but named slightly different each product from each merchant appears.

This is why I added the productid field as mentioned in another thread.

How do I get the pages that display the products by brand and category to group by product id and not by product name? (the search page is being addressed in the other thread)

Submitted by support on Thu, 2007-06-28 09:44

Hi,

For a merchant:, brand: or category: search (which is what is used to display the results when you click a brand or category - it's all done by search.php) the following code results in the grouping by product name (line 45 in the distribution)

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

To change this to productid, simply change this as follows:

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

(where productid is whatever you have called the product ID field in your products table)

This won't affect normal search which uses a different section of search.php!

Cheers,
David.