я делал такое для вирт 1.1 и жоомла 1.0.15(хотя версия жоомлы не важна), но сразу предупреждаю - это точно не лучшее решение так как я нуб в пхп, но зато работает : )
шаг1
в файле ps_product_category.php
после функции function get_subcategory( $category_id, $css_class = "" )(после всей функции, или лучше вообще в конец добавить) а добавил новую функцию
/*Bumbu start*/
function get_all_subcategoryes_b( $category_id=0,
$links_css_class="mainlevel",
$list_css_class="mm123",
$highlighted_style="font-style:italic;" ) {
global $sess;
$categories = ps_product_category::getCategoryTreeArray(); // Get array of category objects
$result = ps_product_category::sortCategoryTreeArray($categories); // Sort array of category objects
$row_list = $result['row_list'];
$depth_list = $result['depth_list'];
$category_tmp = $result['category_tmp'];
$nrows = sizeof($category_tmp);
// Copy the Array into an Array with auto_incrementing Indexes
$key = array_keys($categories); // Array of category table primary keys
$nrows = $size = sizeOf($key); // Category count
$html = "";
// Find out if we have subcategories to display
$allowed_subcategories = Array();
if( !empty( $categories[$category_id]["category_parent_id"] ) ) {
// Find the Root Category of this category
$root = $categories[$category_id];
$allowed_subcategories[] = $categories[$category_id]["category_parent_id"];
// Loop through the Tree up to the root
while( !empty( $root["category_parent_id"] )) {
$allowed_subcategories[] = $categories[$root["category_child_id"]]["category_child_id"];
$root = $categories[$root["category_parent_id"]];
}
}
// Fix the empty Array Fields
if( $nrows < count( $row_list ) ) {
$nrows = count( $row_list );
}
//Bumbu test
for($n = 0 ; $n < $nrowsz ; $n++) {
if ( $depth_list[$n] == 0 ) {unset($keyz[$n]);};
}
// Now show the categories
for($n = 0 ; $n < $nrows ; $n++) {
if ($category_id == $category_tmp[$row_list[$n]]["category_parent_id"] )
{
$allowed_subcategories2[] = $category_tmp[$row_list[$n]]["category_child_id"];
};
}
$allowed_subcategories1 = $allowed_subcategories2;
for ($i = 0; $i < count($allowed_subcategories2) ; $i++){
for($n = 0 ; $n < $nrows ; $n++) {
if ($allowed_subcategories2[$i] == $category_tmp[$row_list[$n]]["category_parent_id"] )
{
$allowed_subcategories3[] = $category_tmp[$row_list[$n]]["category_child_id"];
}
}
}
$allowed_subcategories1 = array_merge($allowed_subcategories1,$allowed_subcategories3);
for ($i = 0; $i < count($allowed_subcategories3) ; $i++){
for($n = 0 ; $n < $nrows ; $n++) {
if ($allowed_subcategories3[$i] == $category_tmp[$row_list[$n]]["category_parent_id"] )
{
$allowed_subcategories4[] = $category_tmp[$row_list[$n]]["category_child_id"];
}
}
}
$allowed_subcategories1 = array_merge($allowed_subcategories1,$allowed_subcategories4);
for ($i = 0; $i < count($allowed_subcategories4) ; $i++){
for($n = 0 ; $n < $nrows ; $n++) {
if ($allowed_subcategories4[$i] == $category_tmp[$row_list[$n]]["category_parent_id"] )
{
$allowed_subcategories5[] = $category_tmp[$row_list[$n]]["category_child_id"];
}
}
}
$allowed_subcategories1 = array_merge($allowed_subcategories1,$allowed_subcategories5);
return $allowed_subcategories1;
}
/*Bumbu end*/
шаг 2
файл shop_browse_queries.php
после mm_showMyFileName( __FILE__ );
добавил
require_once (CLASSPATH."ps_product_category.php");
для подгрузки файла с функцией, и далее у меня получилась при замене некоторых рядов начиная с 61(это у меня 61-ый ряд)
получилось вот это
// Filter Products by Category
if( $category_id ) {
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
} elseif( empty( $keyword ) && empty( $manufacturer_id )) {
$ps_product_category = new ps_product_category();
$bumbucatid = $ps_product_category->get_all_subcategoryes_b($category_id);
$sq .= "\n (`#__{vm}_product_category_xref`.`category_id`=".$category_id." OR ";
for($i = 0; $i < count($bumbucatid); $i++){
$sq .= "\n `#__{vm}_product_category_xref`.`category_id`=".$bumbucatid[$i]." OR ";
}
$sq .= "\n `#__{vm}_product_category_xref`.`category_id`=9999 ) ";
$where_clause[] = $sq;
}
}
а чтоб не показывались ссылки на подкатегории просто это нужно удалить из шаблона магазина в файле
components/com_virtuemart/themes/default/templates/common/categoryChildlist.tpl.php то что выводит подкатегорий(тоесть почти всё или даже всё)
надеюсь поможет, я тоже в своё время искал и не нашёол, пришлось самому делать.