Categories By Name/Alphabetical Ver. 2

Here is how to have your categories sorted alphabetically in CS 2.0.

Just a simple change in BLUE in: /core/fn.catalog.php

// --------------------------------------
// Gets all visible nodes of the category, start from the root
// fn_get_categories(0, true, 234)

function fn_get_categories($params = array(), $lang_code = CART_LANGUAGE)
{
$default_params = array (
‘category_id’ => 0,
‘visible’ => false,
‘current_category_id’ => 0,
‘simple’ => true,
‘plain’ => false,
‘sort_order’ => ‘desc’,
‘limit’ => 0,
‘sort_by’ => ‘name’,
‘item_ids’ => ‘’,
‘group_by_level’ => true,
‘get_images’ => false
);

$params = array_merge($default_params, $params);

woo, thanks for that Tools :wink:



Been meaning to find my way around something like that for a while



Much appreciated!

Not so good. I just tried this and got another mess - all of the (sub)categories are properly sorted in alphabetical order, but I can’t move any of them up/down when mark position eg. 1, 2, 3, etc. Some additional tweak needed.

You can’t use both at the same time. I would suggest that you sort them by “name” then add a position to them then edit the file again by “position”.

What is the perfect solution?

[quote name=‘joe’]What is the perfect solution?[/QUOTE]



Do you want to know how to start a camp fire underwater too?

[quote name=‘Tool Outfitters’]Do you want to know how to start a camp fire underwater too?[/QUOTE]



roban <----------ROFLMAO

hi any way to just do the sub catagorys

[quote name=‘macstudiodesign’]hi any way to just do the sub catagorys[/QUOTE]

Maybe Tool will tell you “how to start a camp fire underwater”. LOL

Hi! I’m using CS-Cart 2.0.15, and although in the past I was able to have my Top Menu Catalog Categories and Sub-Categories sorted alphabetically, I can’t remember how I did it, and some update screwed it up again. Your fix here made my left side-menu categories and sub-cats sort alphabetically again, but not my Top Menu ones. Any idea what file I need to edit to have those sort alphabetically again? Thank you!



Susie


[quote name=‘The Tool’]Here is how to have your categories sorted alphabetically in CS 2.0.



Just a simple change in [COLOR=“Blue”]BLUE[/COLOR] in: /core/fn.catalog.php


// --------------------------------------
// Gets all visible nodes of the category, start from the root
// fn_get_categories(0, true, 234)

function fn_get_categories($params = array(), $lang_code = CART_LANGUAGE)
{
$default_params = array (
'category_id' => 0,
'visible' => false,
'current_category_id' => 0,
'simple' => true,
'plain' => false,
'sort_order' => 'desc',
'limit' => 0,
'sort_by' => '[COLOR="blue"]name[/COLOR]',
'item_ids' => '',
'group_by_level' => true,
'get_images' => false
);

$params = array_merge($default_params, $params);
[/QUOTE]

Susie, I am not sure what you mean. Do you have a link? Changing the above code to “name” should change all instances of categories to alphabetical.

I didn’t know I was allowed to include a link. See www.esbuys.com. You’ll see “Shop our Catalog” on the left will display all cats & sub-cats alphabetically, but the dropdown Catalog on the Top Menu doesn’t. Look under “Electronics,” and you’ll see “Cordless Telephones” sitting at the bottom of the list.



Thank you!


If you change the position of your categories to “0”, the cart will automatically sort alphabetically.



Brandon

I know, but I add new categories fairly often when I add new products with my .csv file that I upload. So if I have to go that way, I have to log-into the Admin part and manually change all of the positions to say 0, which is time-consuming, and sometimes I forget to do it. I know for sure there is a way to have them sort by name instead of position. The fix above already shows this is possible for the side menu, but I can’t remember where to put it for the Top Meno Catalog.


[quote name=‘brandonvd’]If you change the position of your categories to “0”, the cart will automatically sort alphabetically.



Brandon[/QUOTE]

Is there some way that I can make all categories and sub-categories that I import with my .csv file automatically give everything a default “Position” of zero? Same question for how do I do this for my “Feature” I have created called, “Manufacturer?”


Susie, I really don’t know how the drop down is set-up in the top menu. All mine does is go to a page with a list of all of the categories when clicked. It looks like it is still sorting alphabetically except for that particular one. That’s strange.

All (or most) of my other categories are ones where I manually changed their positions to 0. I just created the Cordless Phones sub-category and a few others the other day, and I’d rather not have to manually change their positions to 0 like I’ve been doing for some time now since some update awhile back messed up the alphabetizing. I was just hoping someone knew how to get the Top Menu Catalog to be listed by Name instead of by Position… :confused: