How to hide categories with no active products?
I have several categories that have zero active products. Is there some setting in Zen Cart that will automatically hide any categories that have 0 active products or will this require custom code?
I saw a setting that says Categories with 0 Products Status, but this doesn't have any effect.
I would disable to the categories manually, but this keeps changing depending on the items in stock, so this is very difficult.
Thanks for any info on this.
Re: How to hide categories with no active products
In think that what this mod does
http://www.zen-cart.com/index.php?ma...roducts_id=286
Categories with 0 Products Status just hides the product count for that category so you don't have categories in three with (0)
Re: How to hide categories with no active products
According to the description for that mod, it seems to hide them when the customer chooses to hide them via a selection on a side box.
I'll download that and see how the code works, maybe I can reuse code to make it work the way I want it.
Re: How to hide categories with no active products
I'm in the same boat...the link above to solve this issue is for v1.3. I have version 1.5.1.
I've been trying for weeks to figure out how to hide all subcategories where category counts are 0 of ### active. I have searched in the developers tool kit and looked in the database for anything related to category counts but have came up empty.
I know you can click on the green/red buttons to change the categories. I'm looking for a way to automate it. I have over 7000 products in my store and it's very time consuming to manually go through each category/subcategory to find all of the categories that are 0 of ### active and deactivate them. I don't want to leave them on because that will not give the shopper a very good experience when they click on a category and nothing is there.
I have posted this issue here http://www.zen-cart.com/showthread.p...s-are-inactive but it's not a very active feed.
Where are category counts calculated and stored so that they will display on the admin/categories pages? That is the key I need to finish building my sql statement for taking care of this issue.
If anyone can help, I'd appreciate it.
Re: How to hide categories with no active products
Did you try Configuration->Layout Settings->Categories with 0 Products Status ... and set it to 0 (off)?
Re: How to hide categories with no active products
You could customize the code, using your templates and overrides, for the file:
/includes/templates/templates_default/sideboxes/tpl_categories.php
and add the code in RED:
Code:
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or $box_categories_array[$i]['count'] == 0) {
// skip if this is for the document box (==3)
// skip if this category has no active products
} else {
See if that accomplishes what you are attempting ...
Re: How to hide categories with no active products
I did try that but it has no effect.
Re: How to hide categories with no active products
Quote:
Originally Posted by
mikeel100
I did try that but it has no effect.
Did you try Configuration->Layout Settings->Categories with 0 Products Status ... and set it to 0 (off)?
Re: How to hide categories with no active products
Quote:
Originally Posted by
Ajeh
You could customize the code, using your templates and overrides, for the file:
/includes/templates/templates_default/sideboxes/tpl_categories.php
and add the code in
RED:
Code:
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or $box_categories_array[$i]['count'] == 0) {
// skip if this is for the document box (==3)
// skip if this category has no active products
} else {
See if that accomplishes what you are attempting ...
That made all of my categories disappear...here is the code that I modified with your suggestion.
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or $box_categories_array[$i]['count'] == 0) {
// skip if this is for the document box (==3)
// skip if this category has no active products MIKE
} else {
$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or $box_categories_array[$i]['count'] == 0) {
// skip if this is for the document box (==3)
// skip if this category has no active products MIKE
WHAT DO I NEED TO COMMENT OUT BELOW TO MAKE IT SKIP } else {
$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
Re: How to hide categories with no active products
Quote:
Originally Posted by
lat9
Did you try Configuration->Layout Settings->Categories with 0 Products Status ... and set it to 0 (off)?
It was already set to zero...besides, that is for category counts..."Show Category Count for 0 Products?"
Thanks though.