VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gba on December 17, 2013, 16:50:17 PM

Title: List products in subcategories
Post by: gba on December 17, 2013, 16:50:17 PM
Dear VM pros!

I have i.e. following category hierarchie:
- Cat1
- - Cat1_1
- - - Cat1_1_1
- Cat2
...

On the browsepage I need to display all products not only i.e. of Cat1, but also of Cat1_1 and Cat1_1_1.

Do you have any idea how to achieve that?

Thank you very much in advance for your help!

Best regards,
Gerald
Title: Fw: List products in subcategories
Post by: gba on January 14, 2014, 09:29:32 AM
Hello all!

One month ago I posted about listing products in subcategories.
Does anyone have any idea how to solve that issue?

Best regards
Gerald
Title: Re: List products in subcategories
Post by: gba on September 29, 2016, 15:32:31 PM
*push*  ;)
Title: Re: List products in subcategories
Post by: AH on September 29, 2016, 15:42:41 PM
Develop a plugin?
Title: Re: List products in subcategories
Post by: balai on September 30, 2016, 11:31:13 AM
You did not get a response because the question is vague.

QuoteI have i.e. following category hierarchie:
- Cat1
- - Cat1_1
- - - Cat1_1_1
- Cat2
...

On the browsepage I need to display all products not only i.e. of Cat1, but also of Cat1_1 and Cat1_1_1.

In which browse page? When do you want to get products from these?
Title: Re: List products in subcategories
Post by: Ghost on September 30, 2016, 12:15:46 PM
He wants to display products of child categories in parent category. This can be done with core hack. I'm sure a solution (for VM2) was posted on this forum at some point.

Another option is to assign products to parent categories. This plugin can do it automatically https://extensions.joomla.org/extension/auto-parent-categories-for-virtuemart-joomla-3-x.
Title: Re: List products in subcategories
Post by: balai on September 30, 2016, 13:01:17 PM
Check that
https://extensions.joomla.org/extension/auto-parent-categories-for-virtuemart

It may help
Title: Re: List products in subcategories
Post by: GJC Web Design on September 30, 2016, 23:38:08 PM
there is also a switch in the products model for this ...

see around line 367

if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
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.') ';
}