SEO Friendly Breadcrumbs

This is a simple change you can make in includes/application_top. Instead of the product model number appearing in the Breadcrumbs trail, the product name will appear.

use for OSCommerce versions: 2.2rc2a and 2.3

Instructions:
Open includes/application_top.php.

find:

// add the products model to the breadcrumb trail

if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");

if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

  }

}

change to:

:
// add the products name to the breadcrumb trail

if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");

if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
  }

}

That’s it.

This simply changes the query from the products table to the products_description table where the products name is stored in the products_name field. Since both tables are keyed to the same products id (products_id), the same product is pulled from the database regardless of whether the breadcrumbs query searches the products table or the products_description table.


Posted in SEO