Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / secondary sort order on product listing?

secondary sort order on product listing?

Locked

Views: 1,634

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
28 Jan 2008, 6:40 AM
#1
javamonk avatar

javamonk

New Zenner

Join Date:
Jan 2008
Posts:
3
Plugin Contributions:
0

secondary sort order on product listing?

Hey All,

Is it possible to put a secondary sort on an item in the product listing?

..I'm currently sorting on manufacturer - then within each manufacturer, I need to sort on the model (or perhaps some other field). anyone know if this is possible?

...much thanks, monk

29 Jan 2008, 4:01 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: secondary sort order on product listing?

You would need to alter the ORDER on the SELECT statement where manufacturer is used ...

29 Jan 2008, 5:49 AM
#3
javamonk avatar

javamonk

New Zenner

Join Date:
Jan 2008
Posts:
3
Plugin Contributions:
0

Re: secondary sort order on product listing?

thank you Ajeh for the pointer. you put me in the correct direction.

in case anyone else needs something like this, here's the solution i took:

  • you'll find the SQL that's used for the product listing in :
    <install path>/includes/index_filters/default_filter.php
  • there's a variety of filters (order by) sql you'll find here.. i needed a primary sort on manufacturer (which can be done via the admin : configuration->product listing->display product listing default sort) and a secondary sort on model (vs. the default secondary sort on product name).
    -- so i altered around line 122 from:
    $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
    to:
    $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", p.products_model";

...that did the trick.

thanks- javaMonk();

29 Jan 2008, 5:56 AM
#4
ajeh avatar

ajeh

Oba-san

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

Re: secondary sort order on product listing?

Thanks for posting the solution that worked for you ... :smile: