Claudia M Posted August 31, 2018 Share Posted August 31, 2018 Hi, Is there a way to sort the categories alphabetically in admin/product inventory instead of the custom order of appearance in the Category menu in admin? Thanks for any and all help. Claudia Link to comment Share on other sites More sharing options...
bsmither Posted August 31, 2018 Share Posted August 31, 2018 We need a bit more info. In admin, Products, where is the list of categories you want sorted? Link to comment Share on other sites More sharing options...
Claudia M Posted August 31, 2018 Author Share Posted August 31, 2018 admin - Products - Product Inventory - Where it shows all the products and you can filter by the drop down menu showing the categories. Link to comment Share on other sites More sharing options...
bsmither Posted August 31, 2018 Share Posted August 31, 2018 Ok, not without damaging the result for any other places that want to display the list of categories sorted according to priority. As of CC622, there are no other places that use the function that creates this list. Still, we can modify the function and function call. In /classes/catalogue.class.php, near line 89, find: public function buildCategoriesDropDown($parent_id = 0, $breakout = '|', $spaces = 0) { Change to: public function buildCategoriesDropDown($parent_id = 0, $breakout = '|', $spaces = 0, $priority_sort = true) { Two lines later, find: if (($categories = $GLOBALS['db']->select('CubeCart_category', array('cat_parent_id', 'cat_id', 'cat_name'), array('cat_parent_id' => $parent_id), 'priority, cat_name ASC')) !== false) { Change to: if (($categories = $GLOBALS['db']->select('CubeCart_category', array('cat_parent_id', 'cat_id', 'cat_name'), array('cat_parent_id' => $parent_id), ($priority_sort ? 'priority, cat_name ASC' : 'cat_name ASC') )) !== false) { Seven lines later, find: $out = array_merge($out, $this->buildCategoriesDropDown($category['cat_id'], $breakout, $spaces + 2)); Change to: $out = array_merge($out, $this->buildCategoriesDropDown($category['cat_id'], $breakout, $spaces + 2, $priority_sort)); In the admin /sources/products.index.inc.php, near line 33, find: $cat_dropdown = $GLOBALS['catalogue']->buildCategoriesDropDown(); Change to: $cat_dropdown = $GLOBALS['catalogue']->buildCategoriesDropDown(0,'|',0,false); You might note that the $cat_dropdown statement is inside an if() block that tests for the presence of this list having already been built and cached. As of the latest versions of CubeCart, when working in the admin section, the cache is not used. So, we can presume that this specific list (not sorted by priority) will not be available to any other code that wants a similar list. Link to comment Share on other sites More sharing options...
Claudia M Posted August 31, 2018 Author Share Posted August 31, 2018 Thank you Brian ... again! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.