TheMic Posted February 18, 2019 Share Posted February 18, 2019 Hi, Where I can set the order for the dropdown menu items? I need items in dropdown menu ordered by name thanks Link to comment Share on other sites More sharing options...
TheMic Posted February 18, 2019 Author Share Posted February 18, 2019 Ok... I found a solution on StackOverflow: https://stackoverflow.com/questions/41846364/ordering-categories-alphabetically-in-prestashop-top-menu we need to override the ps_mainmenu with this content: use PrestaShop\PrestaShop\Core\Module\WidgetInterface; class Ps_MainMenuOverride extends Ps_MainMenu implements WidgetInterface { protected function generateCategoriesMenu($categories, $is_children = 0) { $categories = $this->sortCategories($categories); return parent::generateCategoriesMenu($categories, $is_children); } public function sortCategories($categories) { uasort($categories, 'cmpcat'); foreach($categories as $k => $category) { if (isset($category['children']) && !empty($category['children'])) { $children = $this->sortCategories($category['children']); $categories[$k]['children'] = $children; } } return $categories; } } function cmpcat($a, $b) { return strcmp($a['name'], $b['name']); } 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