You are here:  » How do i group searchresults by EAN number?

Support Forum



How do i group searchresults by EAN number?

Submitted by kim on Tue, 2011-01-25 22:43 in

Hello,

don't know where to start. I'm importing EAN data into the products table (into the field "ean") and want to group the products by ean if there is an EAN number, to show the minPrice, maxPrice and numMerchants.

The default sql-query is like this:
$sql = "SELECT SQL_CALC_FOUND_ROWS * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH ".$matchFields." AGAINST ('".database_safe($parts[0])."') AS relevance FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY name";

Is there a way to solve this with just one query? Or do I have to add a sql-query in the searchresults.php within the foreach-region?

Thanks in advance,

Kim

Submitted by support on Wed, 2011-01-26 14:35

Hello Kim,

If not all records are going to have ean values, the best option is actually to run a post import process that matches up product name and ean values. That actually removes the necessity to GROUP BY ean at all, because once they have all be updated GROUPing by name is sufficient.

If you'd like to try this, drop me an email so I can pick up your latest email (I know you've been a user for a long time) and I'll send you a matching script that I have for just this situation...

Cheers,
David.
--
PriceTapestry.com