You are here:  » How to search for a Brand AND a category?

Support Forum



How to search for a Brand AND a category?

Submitted by _M_ on Mon, 2008-12-15 21:45 in

Hi David,

what do i have to do, if i like to search for a specific Brand and a specific Category?

If i enter the following in the search box it dosnt work.

brand:%brandname%:category:%categoryname%:

Thanks for your help!

Best,

Martin

Submitted by support on Tue, 2008-12-16 09:42

Hi Martin,

That style of query can be supported quite easily. In search.php you will find the following code starting on line 36:

      case "merchant":
        // pass through to category
      case "category":
        // pass through to brand
      case "brand":
        $where = " ".$parts[0]."='".database_safe($parts[1])."' ";

To allow another section to be added; add this code on the next line:

        if ($parts[2])
        {
          $where .= " AND ".database_safe($parts[2])."='".database_safe($parts[3])."' ";
        }

...and the query as described in your post should then work!

Cheers,
David.

Submitted by _M_ on Tue, 2008-12-16 13:53

Hi David,

this dosnt work :(

{
      case "merchant":
        // pass through to category
      case "category":
        // pass through to brand
      case "brand":
        $where = " ".$parts[0]."='".database_safe($parts[1])."' ";
        if ($parts[2])
        {
          $where .= " AND ".database_safe($parts[2])."='".database_safe($parts[3])."' ";
        }

Submitted by support on Tue, 2008-12-16 13:57

Hi Martin,

My apologies, I was on the road earlier and didn't check the code far enough ahead for compatibility. There is existing code to look for a 3rd part and search the product name for that. This is done by the following code, which is probably now immediately after where you have included the above modification:

if (isset($parts[2])) if ($parts[2]) $where .= "AND search_name LIKE '%".database_safe(tapestry_search($parts[2]))."%'";

...which would of course stop it from working. If you don't need to be able to search for a category and part of the name; just comment out or delete the above line, and it should then work as described above...

Cheers,
David.