From fce4e79b4df046b284afe6bdc2809c7dc20cd70b Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Wed, 11 Dec 2013 17:31:55 +0100 Subject: [PATCH] [-] MO : BlockLayered - FixBug #PNM-1331 Categories now filtered by groups --- modules/blocklayered/blocklayered.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 7346ca95c..9a7987e7b 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -2190,7 +2190,10 @@ class BlockLayered extends Module break; + case 'category': + $this->user_groups = ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'))); + $depth = Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH'); if ($depth === false) $depth = 1; @@ -2206,9 +2209,11 @@ class BlockLayered extends Module $sql_query['group'] = ') count_products FROM '._DB_PREFIX_.'category c LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category AND cl.`id_shop` = '.(int)Context::getContext()->shop->id.' and cl.id_lang = '.$id_lang.') + RIGHT JOIN '._DB_PREFIX_.'category_group cg ON (cg.id_category = c.id_category AND cg.`id_group` IN ('.implode(', ', $this->user_groups).')) WHERE c.nleft > '.(int)$parent->nleft.' AND c.nright < '.(int)$parent->nright.' '.($depth ? 'AND c.level_depth <= '.($parent->level_depth+(int)$depth) : '').' + AND c.active = 1 GROUP BY c.id_category ORDER BY c.nleft, c.position'; }