Torbz Posted September 26, 2013 Share Posted September 26, 2013 (edited) Hi folks, I realise there's probably thousands of questions on here unanswered, and hope this is not one of those in the making.... Have a look at: http://bluecedaronline.co.uk/index.php?id_category=5&controller=category I need those sub-categories to be sorted alphabetically, rather than respecting the back office ORDER. v.1.5.5 I know it involves this section of category.tpl: {if isset($subcategories)} <!-- Subcategories --> <div id="subcategories"> <h3>{l s='Subcategories'}</h3> <ul class="inline_list"> {foreach from=$subcategories item=subcategory} <li> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}"> {if $subcategory.id_image} <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /> {else} <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /> {/if} </a><br /> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> <br class="clear"/> </div> {/if} But I don't know how the 'array' of $link that gets spat out can be re-organised A > Z There many topics on this subject, but none directly address what I'm trying to achieve and there's not a lot of similar experience out there. I'd appreciate any pointers or help to sort this List. Torbz Edited September 27, 2013 by Torbz (see edit history) Link to comment Share on other sites More sharing options...
puspo Posted January 16, 2014 Share Posted January 16, 2014 I need it too.. so bad, that are no solutions here.. Link to comment Share on other sites More sharing options...
sg1_anhell Posted March 2, 2014 Share Posted March 2, 2014 (edited) Solution: In the /classes/Category.php on the line 532 (Prestashop 1.5.1.0) on the public function getSubCategories Change this: ORDER BY `level_depth` ASC, category_shop.`position` ASC For: ORDER BY cl.name ASC, category_shop.`position` ASC Edited March 2, 2014 by sg1_anhell (see edit history) 3 Link to comment Share on other sites More sharing options...
pets11 Posted April 15, 2014 Share Posted April 15, 2014 Nice! Your solution worked great for 1.5.6.2 on line 536. Link to comment Share on other sites More sharing options...
Angelo Ponzio Posted August 29, 2014 Share Posted August 29, 2014 Nice! Your solution worked great for 1.5.6.2 on line 536. hello, I have made this change, but now it tells me that there are no more subcategories, even if there are BO, why? Link to comment Share on other sites More sharing options...
Angelo Ponzio Posted August 29, 2014 Share Posted August 29, 2014 hello, I have made this change, but now it tells me that there are no more subcategories, even if there are BO, why? to me says that there is no cl.name Link to comment Share on other sites More sharing options...
Angelo Ponzio Posted August 29, 2014 Share Posted August 29, 2014 SOLVED TANKS Link to comment Share on other sites More sharing options...
noesac Posted September 18, 2014 Share Posted September 18, 2014 This helped a lot. I only wanted to reverse the subcategory links so I did something a tiny bit different. I've got v1.4.10 and I changed row 473 from this: ORDER BY `level_depth` ASC, c.`position` ASC'); To this: ORDER BY `level_depth` ASC, c.`position` DESC'); Link to comment Share on other sites More sharing options...
deltahel Posted September 14, 2016 Share Posted September 14, 2016 Solution: In the /classes/Category.php on the line 532 (Prestashop 1.5.1.0) on the public function getSubCategories Change this: ORDER BY `level_depth` ASC, category_shop.`position` ASC For: ORDER BY cl.name ASC, category_shop.`position` ASC Excelente respuesta! Casi la tenía, pero no sabía donde buscar. Link to comment Share on other sites More sharing options...
DoNoVaNS Posted October 21, 2016 Share Posted October 21, 2016 Excelente hilo! Encontré la solución a lo que buscaba. Un saludo amig@s. Link to comment Share on other sites More sharing options...
marcinkukla Posted September 18, 2017 Share Posted September 18, 2017 $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'category` c '.Shop::addSqlAssociation('category', 'c').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').' WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').' '.($active ? 'AND `active` = 1' : '').' '.(!$id_lang ? 'GROUP BY c.id_category' : '').' '.($sql_sort != '' ? $sql_sort : 'ORDER BY c.`level_depth` ASC, category_shop.`position` ASC').' '.($sql_limit != '' ? $sql_limit : '') If i understand it correctly, this set up should sort category by their internal number, right? But in my shop it sorting it alphabeticly. Any idea why? 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