Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how to hide categories without products?


peteravu

Recommended Posts

Posted

Hide Categories & Products http://addons.oscommerce.com/info/5907

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

  • 4 years later...
Posted

I was in search of an automatic way to hide categories with no products and thought i would throw this out on the table.

 

http://addons.oscommerce.com/info/6911 worked good to hide cats in the menu but did not hide the cats on page (index.php ). I used the following query to get closer to acheivement of the goal:

 

<code>$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.categories_id in (select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = c.categories_id) and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");</code>

 

While this is not fully tested for all situations it may help you to get were you want to go. The query was inserted at around line 63 of index.php ( $category_depth['nested'] ). It effectively counted the categories with products prior to building the dynamically displayed table for categories in that section. This would work say in the case the cat staus is flagged one but has no products.

How do you know when you know what you want to do for the rest of your life?

Archived

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

×
×
  • Create New...