Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

List products from category and sub-categories


ourmaninparis

Recommended Posts

Posted

Hello Everybody,

 

I'm new to osCommerce and I am an amateur user. My site contains three levels of categories:

 

Category Level 1

__Category Level 2

____Category Level 3

 

I currently have products within Category Level 3.

 

When I click Category Level 1 I see the sub-categories at the top of the page body and I get the "Featured Products" title but no products underneath. When I click Category Level 2 I see the sub-categories at the top of the page body and underneath are listed the products from Category Level 3. When I click a category from Category Level 3 the products are listed in the page body.

 

I find it confusing that at Category Level 1 there are no "Featured Products" from all sub-categories (Levels 2 and 3). How can I add this feature? I assume I just need to change the code below so that products are pulled from all sub-categories and not just the next category level down.

 

Can you help?

 

Code below taken from index.php

 

// the following cPath references come from application_top.php
 $category_depth = 'top';
 if (isset($cPath) && tep_not_null($cPath)) {
   $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
   $cateqories_products = tep_db_fetch_array($categories_products_query);
   if ($cateqories_products['total'] > 0) {
     $category_depth = 'products'; // display products
   } else {
     $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
     $category_parent = tep_db_fetch_array($category_parent_query);
     if ($category_parent['total'] > 0) {
       $category_depth = 'nested'; // navigate through the categories
     } else {
       $category_depth = 'products'; // category has no products, but display the 'no products' message
     }
   }
 }

 

If this isn't possible then how do I prevent the "Featured Products" title from being displayed when there is nothing to display in the category level immediately below. At the moment it seems to detect that there are products two levels down and hence displays the title (but strangely not the products...)

 

Thanks very much for any help that you can give me.

 

Regards

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...