public static function getNestedCategories($root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') { global $cookie; if (!Module::isInstalled('agilemultipleseller')) { return parent::getNestedCategories($root_category, $id_lang, $active, $groups, $use_shop_restriction, $sql_filter, $sql_sort, $sql_limit); } if (isset($root_category) && !Validate::isInt($root_category)) { die(Tools::displayError()); } if (!Validate::isBool($active)) { die(Tools::displayError()); } if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) { $groups = (array) $groups; } if (intval($cookie->profile) == 0) { $cache_id = 'Category::getNestedCategories_' . md5((int) $root_category . (int) $id_lang . (int) $active . (int) $active . (isset($groups) && Group::isFeatureActive() ? implode('', $groups) : '')); } else { $cache_id = 'Category::getNestedCategories_' . md5((int) $cookie->id_customer . (int) $root_category . (int) $id_lang . (int) $active . (int) $active . (isset($groups) && Group::isFeatureActive() ? implode('', $groups) : '')); } if (!Cache::isStored($cache_id)) { $result = Db::getInstance()->executeS(' SELECT c.*, cl.* FROM `' . _DB_PREFIX_ . 'category` c ' . ($use_shop_restriction ? Shop::addSqlAssociation('category', 'c') : '') . ' LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON c.`id_category` = cl.`id_category`' . Shop::addSqlRestrictionOnLang('cl') . ' ' . (isset($groups) && Group::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON c.`id_category` = cg.`id_category`' : '') . ' ' . (isset($root_category) ? 'RIGHT JOIN `' . _DB_PREFIX_ . 'category` c2 ON c2.`id_category` = ' . (int) $root_category . ' AND c.`nleft` >= c2.`nleft` AND c.`nright` <= c2.`nright`' : '') . ' WHERE 1 ' . $sql_filter . ' ' . ($id_lang ? 'AND `id_lang` = ' . (int) $id_lang : '') . ' ' . ($active ? ' AND c.`active` = 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') . ' ' . ($sql_sort == '' && $use_shop_restriction ? ', category_shop.`position` ASC' : '') . ' ' . ($sql_limit != '' ? $sql_limit : '')); $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) { $categories[$row['id_category']] =& $current; } else { $buff[$row['id_parent']]['children'][$row['id_category']] =& $current; } } Cache::store($cache_id, $categories); } return Cache::retrieve($cache_id); }
/** * Get all nested categories * * @param int|null $root_category * @param bool|int $id_lang * @param bool $active * @param int|null $groups * @param bool $use_shop_restriction * @param string $sql_filter * @param string $sql_sort * @param string $sql_limit * * @return array categories */ public function getNestedCategories($root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') { return \CategoryCore::getNestedCategories($root_category, $id_lang, $active, $groups, $use_shop_restriction, $sql_filter, $sql_sort, $sql_limit); }