Hi.
Thanks to lashae and Creb for the code snippets.
I've rewritten them a little just to store the "untreeCat" in ps_product_category.php and to use the ps_DB class. I tested on VM 1.0.12 and it works.
1. In administrator/components/com_virtuemart/html/shop_browse_queries.php
replace
if( $category_id ) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}
with
if( $category_id ) {
//$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
$kategoriListesi = array();
$ps_product_category->untreeCat($category_id, $kategoriListesi);
$qkat = " `#__{vm}_product_category_xref`.`category_id` IN(".$category_id . ",";
foreach ($kategoriListesi as $kat)
{
$qkat .= $kat . ',';
}
$qkat .= ")";
$qkat = str_replace(',)', ')', $qkat);
$where_clause[] = $qkat;
}
2. In administrator/components/com_virtuemart/classes/ps_product_category.php
add the "untreeCat" function at the end of the class
/*
* Returns an array of the categories ids recursively for a given category
* untreeCat © lashae (virtuemart forum http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0)
* @param int $kat
* @param int $container
* rewritten by haselnuss (to use ps_DB class and store the function in ps_product_category.php)
*/
function untreeCat($kat, &$container) {
$db = new ps_DB;
$q = "SELECT `category_child_id` FROM `#__{vm}_category_xref` WHERE `category_parent_id`=$kat";
$db->query($q);
// if it is a leaf (no data underneath it) then return
if (!$db->num_rows()) {
return;
}
//else append the result, and recurse the function (so to speak)
else
{
while($db->next_record()) {
$container[] = $db->f("category_child_id");
$kat = $db->f("category_child_id");
$this->untreeCat($kat, $container);
}
}
}
Hope this helps someone.
Cya