Print

Show all child category products on the parent category in VirtueMart

GJC added a nice segment of code in /administrator/components/com_virtuemart/model/product.php

At about line 370 you'll find code like this:

  1. //if(true){
  2. // $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
  3. //} else {
  4. /*GJC add subcat products*/
  5. $catmodel = VmModel::getModel ('category');
  6. $childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
  7.  
  8. $cats = $virtuemart_category_id;
  9. foreach($childcats as $childcat){
  10. $cats .= ','.$childcat->virtuemart_category_id;
  11. }
  12. $joinCategory = TRUE;
  13. $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
  14. //}
//if(true){ // $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id; //} else { /*GJC add subcat products*/ $catmodel = VmModel::getModel ('category'); $childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);   $cats = $virtuemart_category_id; foreach($childcats as $childcat){ $cats .= ','.$childcat->virtuemart_category_id; } $joinCategory = TRUE; $where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') '; //}


You'll notice above I commented out the conditions so that only the GJC code is in user and that is how you display all child products in the parent category.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

VirtueMart Admin Menu Not Showing After Update

After running a Joomla and VirtueMart update in place the admin menu dissappears, and this is a...

VirtueMart Show Cart Links not going to SSL

Recently updated a site to VirtueMart 3.0.18.  Had SSL for sensitive areas turned on in the...

Hide the Shopper Information Fields in VirtueMart

Open the file: components/com_virtuemart/views/user/tmpl/edit_shopper.phpor corresponding...

Adding Shopper Group Based Discount in VirtueMart 2

Calculation rules can be added using the instructional located here:...

Setting Payment Module Order

This can be done via the Joomla plugins section on the admin side.  Adjust the order there.