You are here:  » Brand search

Support Forum



Brand search

Submitted by Bob on Mon, 2009-06-15 12:46 in

Hi there,

I would like to search brands and to be able to pull out only those brands that contain a search term e.g. monitor in product names. I have a full text index for (names,brands) created already but I am not having much success with it as I am getting results for all the brands within specified categories in WHERE clause instead of only those brands that contain a search term within product names. Now I have experimented a bit about it but still not sure what is preventing me to get such results. Any help would be appreciated.

Regards.

Bob

Submitted by support on Mon, 2009-06-15 14:10

Hi Bob,

Do you mean that you want to search brands exclusively, as in the query style:

brand:Keyword

..i'm a little confused as you refer to both the product name and category - could you perhaps give a couple of examples of what you want to query and then have returned...?

Cheers,
David.

Submitted by Bob on Mon, 2009-06-15 14:23

Hi David,

I want to search all the brands within certain categories for e.g. monitor in the product name and then have only those brands returned as results that have such term monitor in their product names. So for axample SELECT DISTINCT brand MATCH name AGAINST ('".database_safe($parts[0])."') AS relevance FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND MATCH name AGAINST ('".database_safe($parts[0])."') GROUP BY brand would return all the brands from categories I specified in WHERE clause. But I want to have only those brands that contain the term monitor in their their products (within those categories). Sorry if I am making myself a bit unclear about it.

Regards.

Bob

Submitted by support on Mon, 2009-06-15 15:34

Hi Bob,

The following SQL should do the trick;

$sql = "
SELECT DISTINCT(brand) AS brand
  FROM
    `".$config_databaseTablePrefix."products`
  WHERE
    name LIKE '%".database_safe($parts[0])."%'
    AND
    category IN ('Category 1','Category 2','Category 3')
  ORDER BY brand
";

Hope this helps!

Cheers,
David.

Submitted by Bob on Mon, 2009-06-15 16:16

brilliant...

Thanks David.