Jump to content

[SOLVED] Category product count - count them all!


Recommended Posts

Hello, everybody. I need a little help in here, please. 

 

I am using prestashop 1.5.6.1, and I`d like to do the following: 

-under the breadcrumb, there is a product counter. problem is, that it counts only items in subcategories. I have main categories and plenty of subcategories, and I would like the counter to show the total products fount into every subcategory added when I select a main category (for example: Main cat have 2 subcategories, every subcat having 10 products, then when I select the maincategory, it shows 0 products found, but I want to show 20 products found, the sum of all subcategories)

 

I figure I need to edit the formula in the category-count.tpl, but I`m not good at coding, so please anyone can translate my thoughts so my computer can understand me? :) Thanks a great lot.

 

{if $category->id == 1 OR $nb_products == 0}
{l s='There are no products in  this category'}
{else}
{if $nb_products == 1}
{l s='There is %d product.' sprintf=$nb_products}
{else}
{l s='There are %d products.' sprintf=$nb_products}
{/if}
{/if}

 

Edited by Salus (see edit history)
Link to comment
Share on other sites

it's not a case of .tpl file

it's a case of controllers 

it's necessary to change controller code: controller/front/categoryController.php

 

it will not be as easy as it seems, unfortunately.

 

 

one quesiton

you use block layered navigation module? if not, install it and on module configuration page tick option to display products from subcategories. WIll see if this will change the counter without touching the core

Link to comment
Share on other sites

Oh yes, I found out what this module is all about, installed it all right, but it`ll take me some time to figure out how to configure it, since I dont really need all the features it has. It seems to be a VERY  useful module, thank you for the tip. 

 

It also seems to solve my problem of counting the subcategory products, but only if I set some filters to filter products by, and i dont really know if I need any filters at this stage, and I also have to do some design modifications for this module... I think this module opens up some new perspectives (which I cannot explore yet), give me some time to get deeper into this, and I`ll be back in a couple of days. Until then, please let me leave this thread open as not yet completely solved :) 

Thanks, Vekia.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...