From 6d08c207d77812eacfaad203cfb9f2d9a0550f21 Mon Sep 17 00:00:00 2001 From: Sacha Froment Date: Mon, 6 Oct 2014 12:24:53 +0200 Subject: [PATCH] [-] MO : Fix PSCSX-1466 Categorie disapear --- blocktopmenu.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/blocktopmenu.php b/blocktopmenu.php index aa99ecf..50586c2 100644 --- a/blocktopmenu.php +++ b/blocktopmenu.php @@ -1180,8 +1180,6 @@ class Blocktopmenu extends Module public function customGetNestedCategories($shop_id, $root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') { - - if (isset($root_category) && !Validate::isInt($root_category)) die(Tools::displayError()); @@ -1200,9 +1198,9 @@ class Blocktopmenu extends Module SELECT c.*, cl.* FROM `'._DB_PREFIX_.'category` c INNER JOIN `'._DB_PREFIX_.'category_shop` category_shop ON (category_shop.`id_category` = c.`id_category` AND category_shop.`id_shop` = "'.(int)$shop_id.'") - LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category` AND cl.`id_shop` = "'.(int)$shop_id.'" - WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').' - '.($active ? ' AND c.`active` = 1' : '').' + LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_shop` = "'.(int)$shop_id.'") + WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND cl.`id_lang` = '.(int)$id_lang : '').' + '.($active ? ' AND (c.`active` = 1 OR c.`is_root_category` = 1)' : '').' '.(isset($groups) && Group::isFeatureActive() ? ' AND cg.`id_group` IN ('.implode(',', $groups).')' : '').' '.(!$id_lang || (isset($groups) && Group::isFeatureActive()) ? ' GROUP BY c.`id_category`' : '').' '.($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC').' @@ -1213,15 +1211,12 @@ class Blocktopmenu extends Module $categories = array(); $buff = array(); - if (!isset($root_category)) - $root_category = 1; - foreach ($result as $row) { $current = &$buff[$row['id_category']]; $current = $row; - if ($row['id_category'] == $root_category) + if ($row['id_parent'] == 0) $categories[$row['id_category']] = &$current; else $buff[$row['id_parent']]['children'][$row['id_category']] = &$current;