Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / How do I change the sort order of a category?

How do I change the sort order of a category?

Locked

Views: 13,299

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
1 Oct 2006, 11:48 PM
#1
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

How do I change the sort order of a category?

First, I know of these settings, but they do not do what I'm looking for.

Admin - Product Info - Previous Next - Sort Order
Admin - New Listing - Display Product Display - Default Sort Order
Admin - All Listing - Display Product Display - Default Sort Order

I'm looking to change the default sort order of a specific category. When someone clicks on a category, currently the default is alphabetical. I want it sort by date added.

I believe I have to modify the default_filter.php file in the /includes/index_filters to make this work (maybe not too). I just don't know how to modify it.

2 Oct 2006, 12:05 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I change the sort order of a category?

That is correct ...

You would need some type of conditional sort order where you see:
PRODUCT_LISTING_DEFAULT_SORT_ORDER

in the default_filter.php

Be sure to keep backups of the original file as well as your changed file ...

2 Oct 2006, 12:31 AM
#3
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: How do I change the sort order of a category?

:blush: :blush: :blush:

Could I get some help with that conditional?

I tried changing the $alpha_sort in this code section

// We are asked to show only a specific category
      $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = 1, s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
       from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id , " .
       TABLE_PRODUCTS_DESCRIPTION . " pd, " .
       TABLE_MANUFACTURERS . " m, " .
       TABLE_PRODUCTS_TO_CATEGORIES . " p2c
       where p.products_status = 1
         and p.manufacturers_id = m.manufacturers_id
         and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'
         and p.products_id = p2c.products_id
         and pd.products_id = p2c.products_id
         and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
         and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'" .
      $alpha_sort;
   }

to

   "ORDER by p.products_date_added DESC";

but it didn't do anything. Am in the right place with this or way the hell off base? :unsure:

2 Oct 2006, 1:19 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I change the sort order of a category?

You are hot ... but then, unfortunately so is ... :eek:

Follow the setting that is currently used:
PRODUCT_LISTING_DEFAULT_SORT_ORDER

This is where the setting is set ...

You want to alter that on a per Category basis vs on a single setting for the whole shop ...

2 Oct 2006, 1:41 AM
#5
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: How do I change the sort order of a category?

LOLOL!!

Thank you Linda!

I changed

$listing_sql .= " order by p.products_sort_order, pd.products_name";

to this

$listing_sql .= " order by p.products_date_added DESC, pd.products_name";

and the category products are displaying showing the newest first.

Thank you again! Seems you've been helping me with all my questions lately. Appreciate it immensely!

14 Feb 2007, 10:19 PM
#6
creo_ingero avatar

creo_ingero

New Zenner

Join Date:
Oct 2006
Posts:
40
Plugin Contributions:
0

Re: How do I change the sort order of a category?

Would I use this if I wanted to change the order of all of the categories as they display on the menu to be by date added?

4 Jul 2007, 2:59 AM
#7
mipavluk avatar

mipavluk

Zen Follower

Join Date:
Jun 2007
Location:
Posadas, Misiones, Argentina
Posts:
221
Plugin Contributions:
0

Re: How do I change the sort order of a category?

It also worked for me!!! Thanks! :clap:

20 Dec 2007, 12:17 AM
#8
khopek avatar

khopek

Totally Zenned

Join Date:
Aug 2006
Location:
portlandish, oregon
Posts:
795
Plugin Contributions:
0

Re: How do I change the sort order of a category?

AHHH FINALLY!!!!!!!!!!!! This took me FOREVER to find. I needed all my categories to sort newest to oldest and this worked!

There were to places where this code showed up

$listing_sql .= " order by p.products_sort_order, pd.products_name";

My products didn't sort right til I replaced the second.

Thank you!!!!!!!

19 Sep 2008, 8:15 PM
#9
dark_matter avatar

dark_matter

New Zenner

Join Date:
Sep 2008
Posts:
1
Plugin Contributions:
0

Re: How do I change the sort order of a category?

I realize this is acouple years later and this is a new version of zen cart so how about go to catalog/categories/products and then on your categories click on the green circle with the "e" in it (for edit) and at the bottom of the page on the left enter your sort order...:cool:

27 Sep 2008, 3:45 PM
#10
catia_cunha avatar

catia_cunha

New Zenner

Join Date:
Sep 2008
Posts:
2
Plugin Contributions:
0

Re: How do I change the sort order of a category?

I use this code to change the order of all of the categories as they display on the menu to be by date added.
$listing_sql .= " order by p.products_date_added DESC, pd.products_name";

The category products are displaying showing the newest first. But i have a problem.

When i click in "Item Name" to be list by Name and to replaced the second option. The list continue showing by date added?

Do you understand-me. I´m Brazilian and my English is not good.

Can you help-me?

2 Oct 2008, 5:20 PM
#11
srdejoseph avatar

srdejoseph

New Zenner

Join Date:
Oct 2008
Posts:
15
Plugin Contributions:
0

Re: How do I change the sort order of a category?

Dark Matter:

I realize this is acouple years later and this is a new version of zen cart so how about go to catalog/categories/products and then on your categories click on the green circle with the "e" in it (for edit) and at the bottom of the page on the left enter your sort order...:cool:

This worked perfectly. I finally understand how to sort products. Thank you.

29 Dec 2008, 3:33 PM
#12
marcelarr avatar

marcelarr

New Zenner

Join Date:
Oct 2008
Posts:
54
Plugin Contributions:
0

Re: How do I change the sort order of a category?

Thanks that was so simple and so very usefull!

7 Mar 2009, 5:02 AM
#13
happymom avatar

happymom

New Zenner

Join Date:
May 2006
Posts:
82
Plugin Contributions:
0

Re: How do I change the sort order of a category?

khopek:

AHHH FINALLY!!!!!!!!!!!! This took me FOREVER to find. I needed all my categories to sort newest to oldest and this worked!

There were to places where this code showed up

$listing_sql .= " order by p.products_sort_order, pd.products_name";

My products didn't sort right til I replaced the second.

Thank you!!!!!!!

Also - make sure tha the "Display Product Listing Default Sort Order" option, in your Store->Configuration->ProductList is set to blank/empty. If you put zero, you first product listing page will be sorted correctly, but the next page (using the arrows links and/or the page numbers), will go back to sorting using the "1a" option.