You are here:  » Obtain list of Categories and Brands URLs

Support Forum



Obtain list of Categories and Brands URLs

Submitted by suffolk66 on Wed, 2012-02-15 08:53 in

Is there an easy way of obtaining a list of categories and brands on my sites so that I can ping them? If I view the html on the Categories or Brands page, there's just code.

Submitted by support on Wed, 2012-02-15 11:35

Hi,

Sure - as a text file output have a go with the following:

<?php
  
require("includes/common.php");
  
header("Content-Type: text/plain");
  
// CATEGORIES
  
$sql "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` WHERE category <> '' ORDER BY category";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      if (
$config_useRewrite)
      {
        
$href "category/".urlencode(tapestry_hyphenate($product["category"]))."/";
      }
      else
      {
        
$href "search.php?q=category:".urlencode($product["category"]).":";
      }
      print 
"http://".$_SERVER["HTTP_HOST"].$config_baseHREF.$href."\n";
    }
  }
  
// BRANDS
  
$sql "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` WHERE brand <> '' ORDER BY brand";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      if (
$config_useRewrite)
      {
        
$href "brand/".urlencode(tapestry_hyphenate($product["brand"]))."/";
      }
      else
      {
        
$href "search.php?q=brand:".urlencode($product["brand"]).":";
      }
      print 
"http://".$_SERVER["HTTP_HOST"].$config_baseHREF.$href."\n";
    }
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by suffolk66 on Wed, 2012-02-15 14:13

Perfect David. Thank you very much