I have recently installed Virtuemart 2.0.4 on Joomla 2.5. There used to be an option to show the number of products in a category, but I'm not finding that anywhere. Is that still an option and if so where will I find it?
Thanks so much in advance.
Dee
I have the same question.
How can I display the number of products in a category in categories view?
Hello,
For affecting all categories in category view please go to BE-> Configuration -> Shopfront and change the "Max products per view in frontend" with the number you want.
To change the number of products or categories per row go to BE-> Configuration -> Templates and change the "Default number of categories in a row", "default number of products in a row".
If you want to change it only for a specific category then go to the category you want and you can find there the option " Default Number of Products per Row" and other options for the number of products.
If you mean to show the actual number of products as a number this is done by vmPagination inside template category which displays the number of products in the page of total in the category.
Quote from: bytelord on August 07, 2012, 12:31:05 PM
If you mean to show the actual number of products as a number this is done by vmPagination inside template category which displays the number of products in the page of total in the category.
Hi,
Yes, that's what I exactly mean. Let's say I have 3 categories : Bags , Shoes and Shirts . In the categories view I would like to have the total number of products in each category beside the name of the category . For example :
Bags(28) - Shoes(34) - Shirts(118)
The numbers in parentheses indicates how many products exists in each category . In the example above there are 28 products in Bags category.
How can I achieve this?
Thank you
Hello,
Because i use my own custom template i work around a little bit and find a solution for you.
In the category template (default.php) around line 106 (vm default template) in your custom template you can place the following code that uses the category model of VM models. I suggest you that solution so there is no need to override core files.
$categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($this->category->virtuemart_category_id );
The first line assign the model and the second one echo the products number for the category. You can work around and place that code where you need it, you can use some html/css to style it as you wish, like place "(", color, size, etc.
$categoryModelkaraoke --> use a variable as you wish, like $CatModc
This code snippet is for category-view.
Hope helps you out and may helps some other users that need it.
If that solution works for you please mark the thread as solved. Also this thread should be under Templating & Layouts. Please correct it.
Best Regards,
BL
Thank you so much, Bytelord. I'll give it a try and let you know :)
Hi,
I added the code to line 106 of category/tmpl/default.php but it's not working properly and doesn't count the products. After adding the code a Zero(0) is displayed beside the category names :
Shoes 0 - Bags 0 - Shirts 0
Lines 106-108 of default.php are like this :
<?php echo $category->category_name ?>
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($this->category->virtuemart_category_id ); ?>
Any idea?
Hello,
My apologies, i had test the code for the current category and no children categories! :)
Please inside category/default.php in your template after the following line (where the subcategories are print-out)
<?php echo $category->category_name ?>
add the following code:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($category->virtuemart_category_id ); ?>
i test it and works great for all subcategories.
Thank you
Regards,
Bytelord
Hello
I have try your suggestion onto Virtuemart 2.0.8e but it don't work :(
Any idea??
Thank you Miriam
Hello miriame,
Is working. I test it again on VM default template com_virtuemart\views\category\tmpl\default.php.
Be sure that you have place these two lines of code after line 106 (<?php echo $category->category_name ?>) and before </br>. The two lines:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($category->virtuemart_category_id ); ?>
All the children categories shows correctly the number of products beside name e.g. Children Category1 20 Children Category2 10, etc.
This code above is for category view!
Also you can place that two lines of code in default_categories.php under VM frontpage template (com_virtuemart\views\virtuemart\tmpl\default_categories.php) after line 57 and also works great if you want your master categories shows that number of products (not for children categories product number).
If you want it for category module (mod_virtuemart_category) just let me know!
Thanks. Hope it helps you out.
Regards,
BL
The code worked just fine. Thank you so much BL:)
Hello karaoke,
That's nice. i'm glad it helps! :)
don't forget to mark your thread as solved.
Regards,
BL
Hello bytelord Thank you very much for your hrlp.
I have made the changes onto Virtuemart 2.0.10 and it's work fine.
Thank you very much :D
Hi bytelord,
Thanks but the code didn't work for me. Any help will be appreciated.
Hello,
Is working vm2012f also. You should placed that code after line 111, after the <?php echo $category->category_name ?>
But please make a template override for that and do not edit the vm default theme because after a vm upgrade you will the changes.
to make a template override just copy the file joomla_folder\com_virtuemart\views\category\tmpl\default.php to joomla_folder/template/your_joomla_template/html/com_virtuemart/category/default.php
but, did you use already template overrides so you should edit the file joomla_folder/template/your_joomla_template/html/com_virtuemart/category/default.php that already exists???
The actual code for Children categories:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo '('.$categoryModelkaraoke->countProducts($category->virtuemart_category_id ).')'; ?>
The above will return Chrilder_category name (x_number_of_products)
Some more information regarding templates:
template overrides: http://forum.virtuemart.net/index.php?topic=98505.0
Using the template system: http://dev.virtuemart.net/projects/virtuemart/wiki/Hints_for_the_use_of_the_template_system.
Regards
Hi bytelord,
Thanks its started to work but its returning (0) products for all the subcats whereby there are products under them Help please. Thanks
any live url?
Hi Bytelord
Thanks I have just figured it out that it is working but the count is not right. You can see it at http://www.myghanashop.com/index.php/4/cars
See BMW says 8 products but its actually 9. Is it counting the products by vendor? Also the food category has 1 product under Fruits and vegetables but it says 0. This is at http://www.myghanashop.com/index.php/3/food
Thanks
hello,
works for me ... you are using a commercial template but should work also, i think is not counted products with 0price ... am i right?
Regards
Thanks for figuring that out but am not sure. Will check and get back to you. Thanks
may be that products assigned to other subcategory?
The countProducts function works fine .. do you use multivendor?
public function countProducts($cat_id=0) {
if(!empty($this->_db))$this->_db = JFactory::getDBO();
$vendorId = 1;
if ($cat_id > 0) {
$q = 'SELECT count(#__virtuemart_products.virtuemart_product_id) AS total
FROM `#__virtuemart_products`, `#__virtuemart_product_categories`
WHERE `#__virtuemart_products`.`virtuemart_vendor_id` = "'.(int)$vendorId.'"
AND `#__virtuemart_product_categories`.`virtuemart_category_id` = '.(int)$cat_id.'
AND `#__virtuemart_products`.`virtuemart_product_id` = `#__virtuemart_product_categories`.`virtuemart_product_id`
AND `#__virtuemart_products`.`published` = "1" ';
$this->_db->setQuery($q);
$count = $this->_db->loadResult();
} else $count=0 ;
return $count;
Yes I use multivendor called vm vendor. What should I do with that code and where should I put it? Also am not sure why my product prices aren't showing at all. Any extra help please?
hm,
You could change that function query load to select multivendor ... but i am afraid maybe other issues will be caused ... so i am not aware at the moment what issues could that create ...
try to play around with the following function that is located under joomla_folder\administrator\components\com_virtuemart\helpers\shopfunctions.php ... but this is a core hack and i am not suggested to change it because may be have side effects and your shop does not work properly after. I think that solution works only for one vendor at the moment and multivendor is under development.
public function countProducts($cat_id=0) {
if(!empty($this->_db))$this->_db = JFactory::getDBO();
$vendorId = 1;
if ($cat_id > 0) {
$q = 'SELECT count(#__virtuemart_products.virtuemart_product_id) AS total
FROM `#__virtuemart_products`, `#__virtuemart_product_categories`
WHERE `#__virtuemart_products`.`virtuemart_vendor_id` = "'.(int)$vendorId.'"
AND `#__virtuemart_product_categories`.`virtuemart_category_id` = '.(int)$cat_id.'
AND `#__virtuemart_products`.`virtuemart_product_id` = `#__virtuemart_product_categories`.`virtuemart_product_id`
AND `#__virtuemart_products`.`published` = "1" ';
$this->_db->setQuery($q);
$count = $this->_db->loadResult();
} else $count=0 ;
return $count;
Hi bytelord,
Many thanks for your generous support. I have used an alternative but you have opened my eyes more. Thanks
Hello,
Great you find a solution, you could share if you like.
Regards
Hi,
Just like you said, your solution works only for a single vendor and that is the super user, which suggests that vm only counts for products added by the super user and not other users. In order for other users products to be counted, I had to make every vendor a super user which will be stupid for me to do so. I have rather used a module which displays the categories in list form and which counts every product individually by category. I am happy with it so far. Saying so, I will be happy to revert back to the original if an update or a hack is available. Many thanks for your efforts.
Hello,
You could try to add a new function similar to the countProducts inside category model for all vendors to use it. Inside the file joomla_folder\administrator\components\com_virtuemart\models\category.php around line 375 after the coundProducts function (no matter where but easier to locate it). So please try the add following code inside models\category.php:
/**
* count the products in a category for all Vendors
*
* @author RolandD, Max Milbers, Bytelord
* @return array list of categories product is in for all vendors
*/
public function countAllVendorsProducts($cat_id=0) {
if(!empty($this->_db))$this->_db = JFactory::getDBO();
if ($cat_id > 0) {
$q = 'SELECT count(#__virtuemart_products.virtuemart_product_id) AS total
FROM `#__virtuemart_products`, `#__virtuemart_product_categories`
WHERE `#__virtuemart_product_categories`.`virtuemart_category_id` = '.(int)$cat_id.'
AND `#__virtuemart_products`.`virtuemart_product_id` = `#__virtuemart_product_categories`.`virtuemart_product_id`
AND `#__virtuemart_products`.`published` = "1" ';
$this->_db->setQuery($q);
$count = $this->_db->loadResult();
} else $count=0 ;
return $count;
}
After that inside your category default template you will use the following code:
<?php $categoryModel= VmModel::getModel('category');
echo '('.$categoryModel->countAllVendorsProducts($category->virtuemart_category_id ).')'; ?>
I haven't test it but you could test and please report if is working...
Regards
Hi bytelord,
You have solved my biggest problem. Your solution worked very good. You can check on my site. Every product is counted by your hack and it is just how I wanted it. I don't know how to thank you. You are very good and helpful. Wish everyone was like you. I did a template override as well so hopefully no update will mess it up. Thank you very much!!!
Glad i helped :)
Regards
Hi bytelord,
Sorry to bother you again but I thought I did a template override, not sure what happened but the new VM update messed the hack up so its not working anymore. I know am asking too much but if you have some spare time, can you please look into the hack to show all vendor products count in VM update 2.0.14. Thanks
Hello,
Yes this is normal because the joomla_folder\administrator\components\com_virtuemart\models\category.php file have been re-written from the new version. You cannot override the core files. So please re-add the functions on my previous post again inside the file around line 375
Regards
That's awesome!. Thanks bytelord!
hello evry one i am new1 over here .... i am using joomla 2.5 and virtumart 2.0.14 and i want to get the total number of product under one category in mu default view of category ..,, plz any1 help..... how to get total number of product.......... from countproduct() i want it in default.php of category....
@ravi
If you don't use multivendor please use these 2 lines on the same post: http://forum.virtuemart.net/index.php?topic=102174.msg366816#msg366816
Follow the instructions please and READ all the thread a little bit better to cover your questions.
Regards
I tried that.. No luck
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<?php // if ($category->ids) {
echo '<span class="category_image">' . $category->images[0]->displayMediaThumb("",false) . '</span>';
//} ?>
<!-- this was added to show the number of products in the category -->
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($category->virtuemart_category_id ); ?>
</a>
</h2>
</div>
</div>
I have attached the code here as well. its not working.. Can you please help
Hello,
Please tell me your vm2 version, where did you attach this file? Did you create a template override?
my VM version is 2.0.12f
I override the template category.php as well as the default.php in core joomla category folder
Hello,
Template category.php?? and also default.php in core joomla category folder!~!
Quote from: bytelord on November 02, 2012, 14:35:28 PM
But please make a template override for that and do not edit the vm default theme because after a vm upgrade you will the changes.
to make a template override just copy the file joomla_folder\com_virtuemart\views\category\tmpl\default.php to joomla_folder/template/your_joomla_template/html/com_virtuemart/category/default.php
but, did you use already template overrides so you should edit the file joomla_folder/template/your_joomla_template/html/com_virtuemart/category/default.php that already exists???
The actual code for Children categories:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo '('.$categoryModelkaraoke->countProducts($category->virtuemart_category_id ).')'; ?>
The above will return Chrilder_category name (x_number_of_products)
Some more information regarding templates:
template overrides: http://forum.virtuemart.net/index.php?topic=98505.0
Using the template system: http://dev.virtuemart.net/projects/virtuemart/wiki/Hints_for_the_use_of_the_template_system.
Regards
If its overridden it wont do any difference. But I have remove the core modifying thing.
But still no luck.
Can you please help
Unfortunately I cant update the Virtuemart as the template I have is cannot support for new versions
Hello,
i cannot give you instructions for the specific template you are using because it could be use it's own framework that i am not aware. The code snippets here is working great for users using their own template overrides and for the most commercial templates. Without more information i cannot help you. The only thing is to place that code inside category view after the <?php echo $category->category_name ?>
In your code example:
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<!-- this was added to show the number of products in the category -->
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo '('.$categoryModelkaraoke->countProducts($category->virtuemart_category_id ).')'; ?>
<?php // if ($category->ids) {
echo '<span class="category_image">' . $category->images[0]->displayMediaThumb("",false) . '</span>';
//} ?>
</a>
</h2>
</div>
</div>
This should work fine from version 2.0.6 to 2.0.14
Regards
I am using istore template and Helix framework.
can I send you a private message with the webaddress as its not good to spam in here.
Thanks for replying for my messages even..
Hello,
Sorry i could not work on your template, you should ask support from them, i am not aware how the helix framework is working and also the vm2 template. That solution is working for everyone with third party or not templates.
http://forum.virtuemart.net/index.php?topic=108212.0
Regards
Thanks a lot.
I dont think i will get support from those people. When I need help they asked me just to install Template quickpack rather than helping to solve the issue.
even their Quick pack was not working :(
Anyway thanks a lot
Hello,
Sorry for hearing that, at least they could told you where the joomla/vm overridden files are been located.
So you have to locate the overridden file category/default.php. Try to look under:
joomla_root_folder/templates/helix_template/html/com_virtuemart/category/default.php
i download also helix framework to take a look and as i see is a plugin, didn't install it, but please take a look under the following:
joomla_root_folder/plugins/system/helix/html/com_virtuemart/category/default.php
Regards
Hello,
Your solution works great on children category ... but when i check main category the total is 0 ... under main category i have 4 category with 4 products in it ,,,
Why on main category i dont see 16 instead of 0 ??
Stefan
Do you mean main category or under shop front page (vm home page)?
Regards
Mean main category ... but also the home page ( not the category module )
Stefan
This solution haven't to do with category module or vm front page, needs to modified a little bit. But again, please explain me ... if you enter a main category, on the category view shows the number of products next to sub category name ... i think you wan't to do something else because i know a lot o people using it and working fine...
Ok will try to be more precise ...
I have caterogies build that way :
Main -- Inkjet (0)
Sub Main -- Brother (0)
Sub Brother -- MFC series (0)
Sub MFC series -- MFC 240 (4)
For the product count i have a number only on MFC-240 category ... all the other 3 up level i have 0 ...
Is it clear that way ??
Provide a live url with that code implemented to take a look
If there is no products on the sub category then will not count the product of the all the category tree ... this needs a loop to find and count all the products under a main category including sub categories on all trees...
here it is http://dr-ink.ca/jupgrade/index.php?option=com_virtuemart&view=category&virtuemart_category_id=3678&lang=en
Hello,
You are using a commercial template and i am not aware for the modifications that took place inside the overrides. Also when i open a product is empty, may be you are placing that code in the wrong line because i see also on your product 0 ... please follow the instructions here or ask you template provider to help you if you can't do it... http://forum.virtuemart.net/index.php?topic=102174.msg354185#msg354185
The lines are different for your template
Also please read: http://forum.virtuemart.net/index.php?topic=108212.0
Regards
Do anyone know that they have a extension like this so we can easily install and get it working.
Quote from: bytelord on December 17, 2012, 22:20:33 PM
Hello,
You are using a commercial template and i am not aware for the modifications that took place inside the overrides. Also when i open a product is empty, may be you are placing that code in the wrong line because i see also on your product 0 ... please follow the instructions here or ask you template provider to help you if you can't do it... http://forum.virtuemart.net/index.php?topic=102174.msg354185#msg354185
The lines are different for your template
Also please read: http://forum.virtuemart.net/index.php?topic=108212.0
Regards
I understand , this mod works in part ... what i need is when showing total product i want it to count also all the product in sub categories ...ie
Whant my brother mfc series to show total of producs including all the categories under brother mfc series ...
Hello,
I have to work on that and don't have the time right now. Sorry
May be some time create a free plugin for that (category view and product module).
I want to add this code to the Virtuemart core module category list.
Is it possible. How can I add this code so when I add the Category module it will show with # of products
Hello,
Create a template override for the category module template and use the same code inside the loop (for each categories as category). Load the model before the loop:
$categoryModel= VmModel::getModel('category');
but i think the model already loaded in the help file, so may be not need it ... then when make each $cattext like
$cattext = $category->category_name . $categoryModel->countProducts($category->virtuemart_category_id ).')';
Regards
Ok bytelord will wait to hear from you ...
Quote from: bytelord on December 20, 2012, 13:23:13 PM
Hello,
Create a template override for the category module template and use the same code inside the loop (for each categories as category). Load the model before the loop:
$categoryModel= VmModel::getModel('category');
but i think the model already loaded in the help file, so may be not need it ... then when make each $cattext like
$cattext = $category->category_name . $categoryModel->countProducts($category->virtuemart_category_id ).')';
Regards
Tried this code ....:( still give me same result a before .... snif !
Quote from: bytelord on August 08, 2012, 21:29:09 PM
Hello miriame,
Is working. I test it again on VM default template com_virtuemart\views\category\tmpl\default.php.
Be sure that you have place these two lines of code after line 106 (<?php echo $category->category_name ?>) and before </br>. The two lines:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($category->virtuemart_category_id ); ?>
All the children categories shows correctly the number of products beside name e.g. Children Category1 20 Children Category2 10, etc.
This code above is for category view!
Also you can place that two lines of code in default_categories.php under VM frontpage template (com_virtuemart\views\virtuemart\tmpl\default_categories.php) after line 57 and also works great if you want your master categories shows that number of products (not for children categories product number).
If you want it for category module (mod_virtuemart_category) just let me know!
Thanks. Hope it helps you out.
Regards,
BL
Quote from: bytelord on August 08, 2012, 21:29:09 PM
Hello miriame,
Is working. I test it again on VM default template com_virtuemart\views\category\tmpl\default.php.
Be sure that you have place these two lines of code after line 106 (<?php echo $category->category_name ?>) and before </br>. The two lines:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($category->virtuemart_category_id ); ?>
All the children categories shows correctly the number of products beside name e.g. Children Category1 20 Children Category2 10, etc.
This code above is for category view!
Also you can place that two lines of code in default_categories.php under VM frontpage template (com_virtuemart\views\virtuemart\tmpl\default_categories.php) after line 57 and also works great if you want your master categories shows that number of products (not for children categories product number).
If you want it for category module (mod_virtuemart_category) just let me know!
Thanks. Hope it helps you out.
Regards,
BL
Hy All!
I reading and reading... :D But my english ... not good :D
So. If i understand this topic, Bytelord make a code. This code can count product in categories and show on categori page. It's ok, but a can't understand, how can i use it on category module ( this link: http://gsmmuzeum.hu/gsmnew/index.php?option=com_virtuemart&view=categories&virtuemart_category_id=0&Itemid=104 left side Telefonok: Alcatel, Benefon, etc ) How can i show the product number here? If the ansver is here, sorry, i can't understand evrythig :D just learning english :D
Best regards from Hungary. Scargo
Up...
So, does anyone know how I can display the products number in category module?
Thx.
Scargo
Hi
Check that extension
http://breakdesigns.net/extensions/custom-filters
Its in the free version
Thx Balai!
It'a good idea. But i can't use the sub categories with this... :( Seeking further....
Quote from: Scargo on February 05, 2013, 16:26:49 PM
Thx Balai!
It'a good idea. But i can't use the sub categories with this... :( Seeking further....
What you mean? It offers a foldable category tree in unlimited depth.
If you want to have the parent categories as links, its in the PRO version
Quote from: balai on February 05, 2013, 16:38:35 PM
Quote from: Scargo on February 05, 2013, 16:26:49 PM
Thx Balai!
It'a good idea. But i can't use the sub categories with this... :( Seeking further....
What you mean? It offers a foldable category tree in unlimited depth.
If you want to have the parent categories as links, its in the PRO version
It's ok, but my financial situation allows just the free versions now. It's not problem. This site the just for fun category. I think it's will be great with simple solutins.
Thanks for your help, i saved it for the future use.
(sorry for my english - google translate :) )
Hi all
Will this solution also work for the category module? I looked in the files for the module but couldnt find any place where i could place the code.
Cheers
Quote from: bytelord on August 08, 2012, 21:29:09 PM
Hello miriame,
Is working. I test it again on VM default template com_virtuemart\views\category\tmpl\default.php.
Be sure that you have place these two lines of code after line 106 (<?php echo $category->category_name ?>) and before </br>. The two lines:
<?php $categoryModelkaraoke= VmModel::getModel('category');
echo $categoryModelkaraoke->countProducts($category->virtuemart_category_id ); ?>
All the children categories shows correctly the number of products beside name e.g. Children Category1 20 Children Category2 10, etc.
This code above is for category view!
Also you can place that two lines of code in default_categories.php under VM frontpage template (com_virtuemart\views\virtuemart\tmpl\default_categories.php) after line 57 and also works great if you want your master categories shows that number of products (not for children categories product number).
If you want it for category module (mod_virtuemart_category) just let me know!
Thanks. Hope it helps you out.
Regards,
BL
YESSS - Please:
"If you want it for category module (mod_virtuemart_category) just let me know!"
We need the code for category module ;-)
Quote from: encreplus on December 17, 2012, 21:10:54 PM
Ok will try to be more precise ...
I have caterogies build that way :
Main -- Inkjet (0)
Sub Main -- Brother (0)
Sub Brother -- MFC series (0)
Sub MFC series -- MFC 240 (4)
For the product count i have a number only on MFC-240 category ... all the other 3 up level i have 0 ...
Is it clear that way ??
Same Problem here....
using the override from webnuts...http://www.web-nut.de/webnut-blog/geschreibsel/16-virtuemart-2-category-module-modifizieren.html#.UaxnEpzdXRY
Any suggestion hot to modify the code so that ALL products in Main Category is visible (including products from Sub-Categories) ?
Same problem. Pleeeease help! :)
Here is what i did to change the mod_virtuemart_category to show the number of products in the category. It is not perfect because it doesn't count the total number of products in the child categories yet
Maybe someone can help me out with that. Anyway, this should be a standard feature in VM, in my opinion.
First of all copy the file in /modules/mod_virtuemart_category/tmpl/default.php to /templates/*your template name*/mod_virtuemart_category/default.php to make an override, if it is not allready there.
Then edit the file and search for "$cattext = $category->category_name;" and replace it with "$cattext = $category->category_name. ' ('.$categoryModel->countProducts($category->virtuemart_category_id ).')';"
then search for "$cattext = $child->category_name;" and replace it with "$cattext = $child->category_name. ' ('.$categoryModel->countProducts($child->virtuemart_category_id ).')';"
Save the file and that's it, the number of products will show up next to the category name between brackets.
ok, this is how i solved the problem showing the total number of product in a category with child categories (use the same file as explained in my previous post):
<?php foreach ($categories as $category) {
$active_menu = 'class="VmClose"';
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattotal = 0;
foreach ($category->childs as $child) {
$cattotal = $cattotal + $categoryModel->countProducts($child->virtuemart_category_id );}
//$cattext = $category->category_name. ' ('.$categoryModel->countProducts($category->virtuemart_category_id ).')';
$cattext = $category->category_name. ' ('.$cattotal.')';
//if ($active_category_id == $category->virtuemart_category_id) $active_menu = 'class="active"';
if (in_array( $category->virtuemart_category_id, $parentCategories)) $active_menu = 'class="VmOpen"';
?>
i hope this helps.
How can i do this in com_virtuemart/category/default.php ???
Stefan
Im using this code but it counts only products in the category not all subcategories ...
<h2 class="cat-product-title">
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name.' ('.$categoryModel->countProducts($category->virtuemart_category_id).')'; ?>
</a>
</h2>
How can i count products in subcategories also ...
any news on this ?
Im using this code but it counts only products in the category not all subcategories ...
<h2 class="cat-product-title">
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name.' ('.$categoryModel->countProducts($category->virtuemart_category_id).')'; ?>
</a>
</h2>
How can i count products in subcategories also ...
Quote
Then edit the file and search for "$cattext = $category->category_name;" and replace it with "$cattext = $category->category_name. ' ('.$categoryModel->countProducts($category->virtuemart_category_id ).')';"
then search for "$cattext = $child->category_name;" and replace it with "$cattext = $child->category_name. ' ('.$categoryModel->countProducts($child->virtuemart_category_id ).')';"
It's a good solution but it slows down loading the page :(
I'm using Joomla 3.7.4, Virtuemart 3.2.2 and SW Menu? Would like to show the number of products in each category.
I'm trying to get my number count to show up in the top menu.