[-] MO : BlockLayered - FixBug #PNM-1331 Categories now filtered by groups

This commit is contained in:
Jerome Nadaud
2013-12-11 17:31:55 +01:00
parent bbf2899311
commit fce4e79b4d
+5
View File
@@ -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';
}