News:

Looking for documentation? Take a look on our wiki

Main Menu

Product Count on Category List??

Started by gpullen, August 29, 2012, 14:18:29 PM

Previous topic - Next topic

gpullen

Hi,

Please see the site I am developing here:  http://bfplantsales.com/stock

Is it possible to display a Product Count next to each category... eg  Excavators (4)   like It does in the module I am using on the left hand side??  (IceVMCategories)

Thanks
Gareth

ivus


gpullen

Sorry, temp domain was removed..  Try the link now!!


ivus

Hi gpullen,

looks like you've already figured this one out.

;D

Cornel

Can you share the steps you took to change the code so the number of products in the category is displayed ?

gpullen

What?!!!  noooo!!  Read the first post again!!


The category module on left hand side is IceVMCategories..  it Does that by default.   I want the main bit in the middle of the page to ALSO show product count!!!

Thanks

ivus

Hi gpullen,

wasn't clear enough.

OK 2 step process.

STEP 1 : Modify the MODEL
/administrator/components/com_virtuemart/models/category.php @ line 138.

Look for -


if(!empty($childList)){
if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
foreach($childList as $child){
$xrefTable = new TableCategory_medias($db);
// $xrefTable = $this->getTable('category_medias');
$child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);
}
}



Change to -


if(!empty($childList)){
if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
foreach($childList as $child){
$xrefTable = new TableCategory_medias($db);
// $xrefTable = $this->getTable('category_medias');
$child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);

$categoryModel = VmModel::getModel ('category');
$child->number_of_products =  $categoryModel->countProducts ($child->virtuemart_category_id);

}
}



               $categoryModel = VmModel::getModel ('category');
               $child->number_of_products =  $categoryModel->countProducts ($child->virtuemart_category_id);



STEP 2 : Modify the OUTPUT TEMPLATE
/components/com_virtuemart/views/categories/tmpl/default.php @ line 68.

Look for -


    // Show Category ?>
    <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 ?>
    <br />
    <?php // if ($category->ids) {
    echo $category->images[0]->displayMediaThumb("",false);
    //} ?>

    </a>
    </h2>
    </div>
    </div>



Change to -


    // Show Category ?>
    <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 echo $category->number_of_products ?>)
    <br />
    <?php // if ($category->ids) {
    echo $category->images[0]->displayMediaThumb("",false);
    //} ?>

    </a>
    </h2>
    </div>
    </div>



               <?php echo $category->category_name ?> (<?php echo $category->number_of_products ?>)


AND THAT"S IT...


ivus

did you sort this out? Mark it solved if you have.

kanbosk

Hi Ivus,

Thanks for helping with the code. I had the same problem and implemented your suggestions but they did nothing. Am using virtuemart 2.0.12f and Joomla 2.5.7. Can you help more? Thanks

bytelord

Hello,

No need to hack the core... please take a look over here: http://forum.virtuemart.net/index.php?topic=102174.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!

kanbosk

Hi bytelord
Thanks for your quick response. I have placed the code exactly where you suggested (components/com_virtuemart/views/category/tmpl) and in the exact location but nothing at all happens.
Any ideas? Am using Joomla 2.5.7 and VM 2.0.12f. Thanks

bytelord

lets discuss it on the other thread...
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!