Zen Cart Logo
Forums / General Questions / Listing Sort Order by Date Added

Listing Sort Order by Date Added

Views: 586

Results 1 to 13 of 13
13 Oct 2021, 10:59 AM
#1
girlboheme avatar

girlboheme

New Zenner

Join Date:
Nov 2009
Posts:
17
Plugin Contributions:
0

Listing Sort Order by Date Added

v1.5.7c
It is the latest version, I have just installed.
I have Image Handler installed and that is it.
I used a one click install from my hosting company.
PHP Version: 7.4.12 (Zend: 3.4.0)

URL: https://www.aimeeharrisondesigns.com/store/

I have looked everywhere and cannot find a thread to help me with this.

I simply want to sort all my products by date added. Not alphabetically. I had an old version that did this and I cannot find the instructions to do this using my version.

If anyone can point me in the right direction, that would be great. Or tell me what needs to be changed and I will change it.

Thank you!

13 Oct 2021, 12:14 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Listing Sort Order by Date Added

There's no built in way to do this. If it was me, I'd just modify includes/index_filters/default_filter.php to taste.

13 Oct 2021, 1:34 PM
#3
simon1066 avatar

simon1066

Totally Zenned

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

Re: Listing Sort Order by Date Added

swguy:

There's no built in way to do this. If it was me, I'd just modify includes/index_filters/default_filter.php to taste.

That's how I do it. I replaced line #82 in that file with:

$listing_sql .= " order by p.products_date_added desc, pd.products_name";
13 Oct 2021, 2:57 PM
#4
girlboheme avatar

girlboheme

New Zenner

Join Date:
Nov 2009
Posts:
17
Plugin Contributions:
0

Re: Listing Sort Order by Date Added

Thank you!!

13 Oct 2021, 3:52 PM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Listing Sort Order by Date Added

You might also need to update the SELECT to include this field depending on your database mode - not sure.

13 Oct 2021, 3:56 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Listing Sort Order by Date Added

@simon1066 if you have some free time, writing this up as a documentation article (Developer's side) would be great so people who want to do this can follow a set of steps.

13 Oct 2021, 4:05 PM
#7
simon1066 avatar

simon1066

Totally Zenned

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

Re: Listing Sort Order by Date Added

swguy:

@simon1066 if you have some free time, writing this up as a documentation article (Developer's side) would be great so people who want to do this can follow a set of steps.

Sure, will do.

Edit:

swguy:

You might also need to update the SELECT to include this field depending on your database mode - not sure.

Can I ask what you mean by 'database mode', is it innodb/myisam?

13 Oct 2021, 4:26 PM
#8
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Listing Sort Order by Date Added

swguy:

@simon1066 if you have some free time, writing this up as a documentation article (Developer's side) would be great so people who want to do this can follow a set of steps.

@swguy i think it would be a good PR to be able to override the default_filter.

can we count on you for that? :D

13 Oct 2021, 4:31 PM
#10
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Listing Sort Order by Date Added

carlwhat:

@swguy i think it would be a good PR to be able to override the default_filter.

can we count on you for that? :D

AHEM! I spend the morning documenting sort order on the store front. How 'bout you step up?

13 Oct 2021, 4:50 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Listing Sort Order by Date Added

simon1066:

Sure, will do.

Edit:

Can I ask what you mean by 'database mode', is it innodb/myisam?
Not necessarily those, but in some modes, attempting to sort a data set on a field that is not being returned in the SELECT statement can cause a sql "error"... If the database mode (sql_mode) includes: ONLY_FULL_GROUP_BY then grouping by a field that is not in the select list of that query will cause an error (e.g. ORDER BY clause is not in SELECT list ......) such as if running this query: ```
SELECT products_price FROM products ORDER BY products_id;

13 Oct 2021, 5:40 PM
#12
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Listing Sort Order by Date Added

swguy:

AHEM! I spend the morning documenting sort order on the store front. How 'bout you step up?

i was being a bit facetious.... as i never intended to disparage the work that you do.

if i were to set the odds of said change getting merged into the repo, they would not be very high, as the complexity for said change is a bit high.

as such, i will take a pass...

best.

13 Oct 2021, 7:29 PM
#13
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,763
Plugin Contributions:
9

Re: Listing Sort Order by Date Added

girlboheme:

I used a one click install from my hosting company.To me, this is the most concerning part of the post.
I've yet to find a one-click that doesn't have some little difference that winds up being a big difference later.
I've often seen one-clicks whose internal settings are in direct opposition to the server setup of the host providing the one-click.:blink:

Consider getting the real zip and extracting it into a test folder. Run the install then bring over your current database. It may save you some headaches down the road.