how to get the all products from the child categories using the category filter in the admin panel?
vm3.0.14 j3.5
if interested:
open : administrator/components/com_virtuemart/models/category.php
after : class VirtueMartModelCategory extends VmModel {
insert: function GetTreeCatArray(&$categories, $parent_id = 0) {
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$parent_id.'"';
$db->setQuery($query);
$db->query();
if (empty($categories) && ($parent_id != 0))
array_push($categories, $parent_id);
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($categories, $row[0]);
$this->GetTreeCatArray($categories, $row[0]);
}
}
}
open: /administrator/components/com_virtuemart/models/products.php
replace: $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
on: $categories = array();
VmModel::getModel('category')->GetTreeCatArray($categories, $virtuemart_category_id);
$where[] = ' `pc`.`virtuemart_category_id` in (\'' . implode('\',\'',$categories).'\')';
if only admin panel:
if ($app->isSite ()){$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;}else{
$categories = array();
VmModel::getModel('category')->GetTreeCatArray($categories, $virtuemart_category_id);
$where[] = ' `pc`.`virtuemart_category_id` in (\'' . implode('\',\'',$categories).'\')';}
Quote from: FAUSTddd on April 14, 2016, 06:35:02 AM
if interested:
open : administrator/components/com_virtuemart/models/category.php
after : class VirtueMartModelCategory extends VmModel {
insert: function GetTreeCatArray(&$categories, $parent_id = 0) {
$db = JFactory::getDBO();
$query = 'SELECT `category_child_id` FROM `#__virtuemart_category_categories` WHERE `category_parent_id`="'.$parent_id.'"';
$db->setQuery($query);
$db->query();
if (empty($categories) && ($parent_id != 0))
array_push($categories, $parent_id);
$rows = $db->loadRowList();
if (empty($rows)) {
return;
} else {
foreach($rows as $row) {
array_push($categories, $row[0]);
$this->GetTreeCatArray($categories, $row[0]);
}
}
}
open: /administrator/components/com_virtuemart/models/products.php
replace: $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
on: $categories = array();
VmModel::getModel('category')->GetTreeCatArray($categories, $virtuemart_category_id);
$where[] = ' `pc`.`virtuemart_category_id` in (\'' . implode('\',\'',$categories).'\')';
if only admin panel:
if ($app->isSite ()){$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;}else{
$categories = array();
VmModel::getModel('category')->GetTreeCatArray($categories, $virtuemart_category_id);
$where[] = ' `pc`.`virtuemart_category_id` in (\'' . implode('\',\'',$categories).'\')';}
well said or should I say well done! You just solved my problem. Thanks a lot! an unexpected help is it!