[*] FO : Added the possibility to deactivate customer groups management (for performances) [part 1]
This commit is contained in:
+19
-20
@@ -547,31 +547,30 @@ class CategoryCore extends ObjectModel
|
||||
*/
|
||||
public function getSubCategories($id_lang, $active = true)
|
||||
{
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '='.(int)Group::getCurrent()->id);
|
||||
$sql_groups_where = '';
|
||||
$sql_groups_join = '';
|
||||
if (Configuration::get('PS_GROUP_FEATURE_ACTIVE'))
|
||||
{
|
||||
$sql_groups_join = 'LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)';
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups_where = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '='.(int)Group::getCurrent()->id);
|
||||
}
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
'.Shop::addSqlAssociation('category', 'c').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (c.`id_category` = cl.`id_category`
|
||||
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_group` cg
|
||||
ON (cg.`id_category` = c.`id_category`)
|
||||
WHERE `id_parent` = '.(int)$this->id.'
|
||||
'.($active ? 'AND `active` = 1' : '').'
|
||||
AND cg.`id_group` '.$sql_groups.'
|
||||
GROUP BY c.`id_category`
|
||||
ORDER BY `level_depth` ASC, category_shop.`position` ASC
|
||||
');
|
||||
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
'.Shop::addSqlAssociation('category', 'c').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.(int)$id_lang.' '.Shop::addSqlRestrictionOnLang('cl').')
|
||||
'.$sql_groups_join.'
|
||||
WHERE `id_parent` = '.(int)$this->id.'
|
||||
'.($active ? 'AND `active` = 1' : '').'
|
||||
'.$sql_groups_where.'
|
||||
GROUP BY c.`id_category`
|
||||
ORDER BY `level_depth` ASC, category_shop.`position` ASC');
|
||||
|
||||
foreach ($result as &$row)
|
||||
{
|
||||
$row['id_image'] = file_exists(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') ? (int)$row['id_category'] : Language::getIsoById($id_lang).'-default';
|
||||
$row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') ? (int)$row['id_category'] : Language::getIsoById($id_lang).'-default';
|
||||
$row['legend'] = 'no picture';
|
||||
}
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user