Author Topic: Show number of products in a category.  (Read 22800 times)

bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #30 on: November 19, 2012, 06:36:48 am »
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
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!

kanbosk

  • Beginner
  • *
  • Posts: 12
Re: Show number of products in a category.
« Reply #31 on: November 19, 2012, 12:20:40 pm »
That's awesome!. Thanks bytelord!

ravi

  • Beginner
  • *
  • Posts: 2
Re: Show number of products in a category.
« Reply #32 on: November 29, 2012, 15:03:29 pm »
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....

bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #33 on: November 29, 2012, 16:52:17 pm »

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

  • Jr. Member
  • **
  • Posts: 73
Re: Show number of products in a category.
« Reply #34 on: December 15, 2012, 12:15:51 pm »
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

bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #35 on: December 15, 2012, 12:33:36 pm »
Hello,

Please tell me your vm2 version, where did you attach this file? Did you create a template override?
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

  • Jr. Member
  • **
  • Posts: 73
Re: Show number of products in a category.
« Reply #36 on: December 15, 2012, 20:50:41 pm »
my VM version is 2.0.12f

I override the template category.php as well as the default.php in core joomla category folder


bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #37 on: December 16, 2012, 11:16:00 am »
Hello,

Template category.php?? and also default.php in core joomla category folder!~!

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:

Code: [Select]
<?php $categoryModelkaraokeVmModel::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
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

  • Jr. Member
  • **
  • Posts: 73
Re: Show number of products in a category.
« Reply #38 on: December 16, 2012, 11:43:19 am »
If its overridden it wont do any difference. But I have remove the core modifying thing.

But still no luck.

Can you please help

binarix

  • Jr. Member
  • **
  • Posts: 73
Re: Show number of products in a category.
« Reply #39 on: December 16, 2012, 12:03:00 pm »
Unfortunately I cant update the Virtuemart as the template I have is cannot support for new versions

bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #40 on: December 16, 2012, 12:11:04 pm »
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:

Code: [Select]
<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 $categoryModelkaraokeVmModel::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
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

  • Jr. Member
  • **
  • Posts: 73
Re: Show number of products in a category.
« Reply #41 on: December 16, 2012, 12:53:59 pm »
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..

bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #42 on: December 16, 2012, 13:09:31 pm »
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
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

  • Jr. Member
  • **
  • Posts: 73
Re: Show number of products in a category.
« Reply #43 on: December 16, 2012, 13:21:26 pm »
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

bytelord

  • Nikos
  • Global Moderator
  • Hero Member
  • *
  • Posts: 2369
Re: Show number of products in a category.
« Reply #44 on: December 16, 2012, 14:53:39 pm »
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
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!