Ina Code Blog

bunch of code in one place
« Usefull links
Spletna trgovina za Exclusive d.o.o. »


Mar
18

osCommerce: Add category and product name in title tag

Posted by admin in osCommerce, tips

I’m doing search engine optimization for a shop powered by osCommerce. Title tags are very important for that, so I wanted it to look like this: Shop name :: Category name :: Product name.

If you are using STS (Simple Template System) use:

  1. Open file /catalog/includes/modules/sts_inc/general.php
  2. Find line:

    $sts->template[’headertags’]= “<title>” . TITLE .”</title>”;

    and replace it with:

    // BOF add category and product name in title tag
    $product_title_query = tep_db_query(”select pd.products_name, pd.products_description from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd where p.products_id = ‘” . (int)$HTTP_GET_VARS[’products_id’] . “‘ and pd.products_id = p.products_id and pd.language_id = ‘” . (int)$languages_id . “‘”);
    $product_title = tep_db_fetch_array($product_title_query); // get product name

    $category_query = tep_db_query(”select cd.categories_name, c.categories_image from ” . TABLE_CATEGORIES . ” c, ” . TABLE_CATEGORIES_DESCRIPTION . ” cd where c.categories_id = ‘” . (int)$current_category_id . “‘ and cd.categories_id = ‘” . (int)$current_category_id . “‘ and cd.language_id = ‘” . (int)$languages_id . “‘”);
    $category = tep_db_fetch_array($category_query); // get category name

    $sts->template[’headertags’]= “<title>” . TITLE . ” :: ” . $category[’categories_name’] . ” :: ” . $product_title[’products_name’] . “</title>”;
    // EOF add category and product name in title tag

  3. Upload the file and you’re done!

If you are using basic osCommerce use:

  1. Open file /catalog/index.php
  2. Find line:

    <title><?php echo TITLE; ?></title>

    and buy prescription drugs online replace it with:

    <?php // BOF add category and product name in title tag
    $product_title_query = tep_db_query(”select pd.products_name, pd.products_description from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd where p.products_id = ‘” . (int)$HTTP_GET_VARS[’products_id’] . “‘ and pd.products_id = p.products_id and pd.language_id = ‘” . (int)$languages_id . “‘”);
    $product_title = tep_db_fetch_array($product_title_query); // get product name

    $category_query = tep_db_query(”select cd.categories_name, c.categories_image from ” . TABLE_CATEGORIES . ” c, ” . TABLE_CATEGORIES_DESCRIPTION . ” cd where c.categories_id can you buy cialis without a prescription = ‘” . (int)$current_category_id . “‘ and cd.categories_id = ‘” . (int)$current_category_id . “‘ and cd.language_id = ‘” . (int)$languages_id . “‘”);
    $category = tep_db_fetch_array($category_query); // get category name
    ?>
    <title><?php echo TITLE . ” :: ” . $category[’categories_name’] . ” :: ” . $product_title[’products_name’]; ?></title>

  3. Do the same for file /catalog/product_info.php
  4. Upload files and that’s it!

Note: Page title (TITLE) is found in your language file (for example: /catalog/includes/language/english.php)

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

3 Responses to “osCommerce: Add category and product name in title tag”

  1. Added by Luke on Nov at 10

    hi, my name is luke fro furnitureinfashion.net, we are using basic oscommerce, all title tags are the same as well as product title tags, descriptions… could you help me out thank you…

  2. Added by bar stools on Mar at 3

    any one replying..

  3. Added by Art on Jul at 1

    Excellent! This code worked great for us using STSv4.5.8. Been searching around for a simple fix like this. thanks for the post!!

Leave a Reply

Comment