1

I am using a tree of categories, the last category in the tree has products. All the others have only links to subcategories or texts (static blocks). Here is an example:

Category A --> Category A1 ----> Category A11 ---> Category A111

Category A page has image links to category A1 and texts. Categories A11 has image links to A111. Only A111 has products associated.

"Browse By" side block shows 0 products for a category without products inside (A1 and A11). I would like to keep showing products numbers for categories but only for those which have products inside.

I guess it is an if statement inside a file, but I need advice. This can be solved in an elegant way by using a check box or select dropdown Yes/Now when creating a category. If that category doesn't have products inside, just static blocks, you can select "Not show product count numbers" (in case it is enabled). Based on this option in Browse By you won't get zero products for this category.

As it is now Magento has a seriously logical issues. This is bad because a visitor won't go inside when seeing zero products.

2

So the template that does this display is app/design/frontend/base/default/template/catalog/navigation/left.phtml

What you can do is add a version of this template into your theme and simply change the display of the number only to show when the categories have products.

The original line is as follows:

<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->escapeHtml($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>)

I would suggest something like the following should work:

<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->escapeHtml($_category->getName()) ?></a> <?php if($_category->getProductCount()) > 0):?>(<?php echo $_category->getProductCount() ?>)<?php endif; ?>
| improve this answer | |
1

Have you marked the category as an anchor category in the administrative interface? That should allow child categories' products to show up in the parent category listing.

Make sure you set "Is anchor" to "Yes" for your root category.

Hope that helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.