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

secondary sort order on product listing?

Locked

Started by javamonk on 28 Jan 2008, 6:40 AM · Views: 1,635

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 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

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:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!