You are here:  » List all brands and categories of a merchant

Support Forum



List all brands and categories of a merchant

Submitted by atman on Mon, 2009-04-06 12:03 in

hi david.

Is is possible to setup the merchant links to list all categories and brands under a specific merchant.

Thanks in advance.

Submitted by support on Mon, 2009-04-06 19:42

Hi Alex,

Just to confirm, do you mean on the merchant search results (having clicked a merchant from the Merchant A-Z) you want to show all categories and brands for that merchant as well as the search results?

Cheers,
David.

Submitted by atman on Mon, 2009-04-06 21:59

hi david,

Yes david.

Submitted by support on Tue, 2009-04-07 05:29

Hi Alex,

Sure - to display the lists at the top, look for the following code towards the end of search.php:

  require("html/banner.php");

...and REPLACE this with:

  require("html/banner.php");
  if ($parts[0]=="merchant")
  {
    $sql = "SELECT DISTINCT(category) AS category
            FROM `".$config_databaseTablePrefix."products`
            WHERE merchant='".database_safe($parts[1])."'";
    database_querySelect($sql,$categories);
    $sql = "SELECT DISTINCT(brand) AS brand
            FROM `".$config_databaseTablePrefix."products`
            WHERE merchant='".database_safe($parts[1])."'";
    database_querySelect($sql,$brands);
    print "<table>";
    print "<tr>";
    print "<td valign='top'>";
    if (is_array($categories))
    {
      print "<h4>Categories</h4>";
      print "<ul>";
      foreach($categories as $row)
      {
        if ($config_useRewrite)
        {
          $href = $config_baseHREF."category/".tapestry_hyphenate($row["category"])."/";
        }
        else
        {
          $href = $config_baseHREF."search.php?q=category:".urlencode($row["category"]);
        }
        print "<li><a href='".$href."'>".$row["category"]."</a></li>";
      }
      print "</ul>";
    }
    print "</td>";
    print "<td valign='top'>";
    if (is_array($brands))
    {
      print "<h4>Brands</h4>";
      print "<ul>";
      foreach($brands as $row)
      {
        if ($config_useRewrite)
        {
          $href = $config_baseHREF."brand/".tapestry_hyphenate($row["brand"])."/";
        }
        else
        {
          $href = $config_baseHREF."search.php?q=brand:".urlencode($row["brand"]);
        }
        print "<li><a href='".$href."'>".$row["brand"]."</a></li>";
      }
      print "</ul>";
    }
    print "</td>";
    print "</tr>";
    print "</table>";
  }

Cheers!
David.