Zen Cart Logo
Forums / Customization from the Admin / Product Sort Order Within A Category

Product Sort Order Within A Category

Views: 2,213

Results 1 to 5 of 5
24 Aug 2023, 3:29 PM
#1
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Product Sort Order Within A Category

Hi,

I have read the Zen Cart info on default product sorting and have successfully implemented this on the New Product and All Products but cannot get this to work on the Product Listing.

I am looking to sort products by their date added, descending. As this is not an option in the Config-> Product Listing I am using the product model and have changed it from 0 to 6. When I then go to Display Product Listing Default Sort Order and set it to 6d, the sort order still stays as alphabetical, which it is now.

I am obviously missing something....can someone point me in the right direction??

Thank you in advance for your help.

24 Aug 2023, 4:54 PM
#2
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Product Sort Order Within A Category

This is how I do it,

includes/index_filters/default_filter.php

find the 2nd instance of

$listing_sql .= " ORDER BY p.products_sort_order, pd.products_name";

change to

$listing_sql .= " ORDER BY p.products_date_added desc, p.products_sort_order, pd.products_name";

I believe that the setting
Admin > configuration > product listing > Display Product Listing Default Sort Order
needs to be left blank for this to work.

24 Aug 2023, 5:32 PM
#3
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: Product Sort Order Within A Category

Hi Simon,

Thanks for your help and reply! I'll give this a go later today and will let you know.

Thanks again!

25 Aug 2023, 1:52 PM
#4
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: Product Sort Order Within A Category

Hi again Simon....your code change worked perfectly and I now have the products in each category being sorted by date added.

Thanks very much for your help!

25 Aug 2023, 3:33 PM
#5
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Product Sort Order Within A Category

NWCE:

Hi again Simon....your code change worked perfectly and I now have the products in each category being sorted by date added.

Thanks very much for your help!

Glad to help.