Book Image

Deep Inside osCommerce: The Cookbook

By : Monika Mathe
Book Image

Deep Inside osCommerce: The Cookbook

By: Monika Mathe

Overview of this book

osCommerce has been around since March 2000. At present there are over 10,000 live, registered osCommerce sites, and about 100,000 registered community members. Apart from providing ready-made solutions to problems, as well as a huge repository of information, the osCommerce community is a living entity with which we can all interact. With the rising success and popularity of this remarkable piece of software, things can only get better.
Table of Contents (17 chapters)
Deep Inside osCommerce: The Cookbook
Credits
Foreword
About the Author
About the Reviewers
Introduction

17. Add Parent Category in Product Listing


This recipe displays the parent category along with the product name in product listing. This module is important if your customers find your products using the search function in most cases, and you want them to see the category of each product at a glance.

Presentation

Your screen will look like the following screenshot, with the parent category added to each product name, and separated by a dash:

You can easily hack this recipe to present category name first as shown in the variation later.

Are you ready to carve the roast?

Ingredients

Note

Modified:

catalog/includes/functions/general.php

catalog/includes/modules/product_listing.php

Cooking

  1. 1. Open catalog/includes/functions/general.php and add the following function directly before the closing PHP tag to get the name of the parent category for a given product:

function tep_get_category_name($product_id) {
global $languages_id;
$category_query = tep_db_query("select cd.categories_name from " ...