Jump to content

Category order in admin product inventory


Claudia M

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...