News:

Support the VirtueMart project and become a member

Main Menu

Show number of products in a category.

Started by bmw2182, May 03, 2012, 17:36:30 PM

Previous topic - Next topic

encreplus

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

bytelord

Do you mean main category or under shop front page (vm home page)?

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

encreplus

Mean main category ... but also the home page ( not the category module )

Stefan

bytelord

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...
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

encreplus

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 ??

bytelord

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...

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!


bytelord

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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

binarix

Do anyone know that they have a extension like this so we can easily install and get it working.


encreplus

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 ...


bytelord

#55
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).
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

binarix

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


bytelord

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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

encreplus

Ok bytelord will wait to hear from you ...

encreplus

#59
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 !