BerghemDeSass Posted October 21, 2013 Share Posted October 21, 2013 (edited) when i click on a 1st level categories e get, on central block (classic ps theme) the sub-categories list, then items . How to change default sub-categories order (i need classic a-->z) Edited October 21, 2013 by BerghemDeSass (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 in this case you have to edit Category class: classes/Category.php you've got there function: 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); $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 '); 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['legend'] = 'no picture'; } return $result; } you need to change ORDER BY `level_depth` ASC, category_shop.`position` ASC to ORDER BY `level_depth` ASC, cl.`name` ASC Link to comment Share on other sites More sharing options...
BerghemDeSass Posted October 21, 2013 Author Share Posted October 21, 2013 thanks..... Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 does it work in your ps version? im asking because this code is from latest 1.5.6 Link to comment Share on other sites More sharing options...
BerghemDeSass Posted October 22, 2013 Author Share Posted October 22, 2013 works fine! Link to comment Share on other sites More sharing options...
vekia Posted October 22, 2013 Share Posted October 22, 2013 okay thank you very much for confirmation that it works i never tested it so this is why i asked about that anyway glad to hear that it works as you expected. topic closed with regards, Milos Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now