Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / sort sub-category view by date added

sort sub-category view by date added

Views: 5,172

Results 1 to 15 of 15
4 Apr 2008, 4:49 PM
#1
hpowers avatar

hpowers

New Zenner

Join Date:
Sep 2007
Posts:
10
Plugin Contributions:
0

sort sub-category view by date added

When someone clicks on a subcategory, for example toys-infant. It shows a list of all infant toys. They are in alphabetical order. I would like them to list in the order they were added to the store, so that the newest products come up first.

7 Apr 2008, 1:49 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: sort sub-category view by date added

Currently, the Product Listing is sortable by the fields that you have selected to display ... unfortunately, date added is not one of them ...

You would have to customize the code to sort by date added then product name vs one of the available fields ...

7 Apr 2008, 2:38 AM
#3
hpowers avatar

hpowers

New Zenner

Join Date:
Sep 2007
Posts:
10
Plugin Contributions:
0

Re: sort sub-category view by date added

where would I look for the code that is doing the sorting?

19 Apr 2008, 12:08 AM
#4
moltar avatar

moltar

New Zenner

Join Date:
May 2007
Posts:
43
Plugin Contributions:
0

Re: sort sub-category view by date added

Open the file /includes/index_filters/default_filter.php

Find the line that says (line 113 in default 1.3.7):

$listing_sql .= ' order by ';

Replace with:

$listing_sql .= ' order by p.products_date_added DESC,';

Go to Configuration -> Product Listing -> Display Product Listing Default Sort Order. Set this to anything valid, like "2a" for example. This isn't going to do anything, just activates the part of the code in default_filter.php file that does the sorting.

:blink:

21 Apr 2008, 12:38 AM
#5
hpowers avatar

hpowers

New Zenner

Join Date:
Sep 2007
Posts:
10
Plugin Contributions:
0

Re: sort sub-category view by date added

that worked! Thanks. - Hunter

9 Jul 2008, 2:16 PM
#6
ksoup avatar

ksoup

Zen Follower

Join Date:
Jan 2004
Posts:
413
Plugin Contributions:
1

Re: sort sub-category view by date added

You rock!! Thank you so much! :)

moltar:

Open the file /includes/index_filters/default_filter.php

Find the line that says (line 113 in default 1.3.7):

$listing_sql .= ' order by ';

> 
> Replace with:
> 
> ```php
$listing_sql .= ' order by p.products_date_added DESC,';

Go to Configuration -> Product Listing -> Display Product Listing Default Sort Order. Set this to anything valid, like "2a" for example. This isn't going to do anything, just activates the part of the code in default_filter.php file that does the sorting.

:blink:

22 Jul 2008, 2:44 AM
#7
nashliu avatar

nashliu

New Zenner

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

Re: sort sub-category view by date added

moltar:

Open the file /includes/index_filters/default_filter.php

Find the line that says (line 113 in default 1.3.7):

$listing_sql .= ' order by ';

> 
> Replace with:
> 
> ```php
$listing_sql .= ' order by p.products_date_added DESC,';

Go to Configuration -> Product Listing -> Display Product Listing Default Sort Order. Set this to anything valid, like "2a" for example. This isn't going to do anything, just activates the part of the code in default_filter.php file that does the sorting.

:blink:
I had this problem for several days
finally resolved,thank you very much,moltar

14 Sep 2008, 11:16 PM
#8
pinkchalkstudio avatar

pinkchalkstudio

New Zenner

Join Date:
Apr 2008
Posts:
78
Plugin Contributions:
0

Re: sort sub-category view by date added

I want my most recent products showing first in the sort order on the listing display. This mod worked exactly as I wanted to get that to happen. Thank you.

Now for a follow up question: is anyone familiar with where I would change the code to do the exact same thing for the Previous/Next logic that cycles through the listing on the Product Info page?

I know that is set in the Config/Product Info/Previous Next - Sort Order where date added is not an option so I'm assuming I need to customize just like I did for the product listing page.

Thank you!

16 Sep 2008, 3:02 AM
#9
ajeh avatar

ajeh

Oba-san

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

Re: sort sub-category view by date added

Currently, in the Configuration ... Product Info ... there is a setting for:

Previous Next - Sort Order
Products Display Order by
0= Product ID
1= Product Name
2= Model
3= Price, Product Name
4= Price, Model
5= Product Name, Model
6= Product Sort Order

You would have to customize the code further if you want it to sort by date vs any of the built in settings ...

16 Sep 2008, 3:23 PM
#10
pinkchalkstudio avatar

pinkchalkstudio

New Zenner

Join Date:
Apr 2008
Posts:
78
Plugin Contributions:
0

Re: sort sub-category view by date added

Thank you Ajeh. That's what I thought. Can you point me to the file that contains the Previous/Next SQL statement or what I would search for in order to find it myself?

Thank you!

Kathy

16 Sep 2008, 4:58 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: sort sub-category view by date added

You could peek at the product_prev_next.php module and see where the order is defined from the settings ...

26 Sep 2009, 11:17 PM
#12
lauriesscraps avatar

lauriesscraps

Zen Follower

Join Date:
Sep 2009
Posts:
255
Plugin Contributions:
0

Re: sort sub-category view by date added

moltar:

Open the file /includes/index_filters/default_filter.php

Find the line that says (line 113 in default 1.3.7):

$listing_sql .= ' order by ';

> 
> Replace with:
> 
> ```php
$listing_sql .= ' order by p.products_date_added DESC,';

Go to Configuration -> Product Listing -> Display Product Listing Default Sort Order. Set this to anything valid, like "2a" for example. This isn't going to do anything, just activates the part of the code in default_filter.php file that does the sorting.

:blink:

I tried this and it didn't do anything at all. Can you help me figure out why? I have the right line and everything.

I have the "all products" sorted by date, but I want each of the categories to display that way as well and right now they are sorting by name.

Thanks!

3 Oct 2009, 9:16 PM
#13
missinglife avatar

missinglife

Zen Follower

Join Date:
Apr 2009
Location:
Portland, OR
Posts:
104
Plugin Contributions:
0

Re: sort sub-category view by date added

dont mind me :P, just make a note, do I can have this in file

1 Jun 2011, 8:35 PM
#14
luvstoxstitch avatar

luvstoxstitch

New Zenner

Join Date:
Jun 2010
Location:
Ohio
Posts:
36
Plugin Contributions:
0

Re: sort sub-category view by date added

moltar:

Open the file /includes/index_filters/default_filter.php

Find the line that says (line 113 in default 1.3.7):

$listing_sql .= ' order by ';

> 
> Replace with:
> 
> ```php
$listing_sql .= ' order by p.products_date_added DESC,';

Go to Configuration -> Product Listing -> Display Product Listing Default Sort Order. Set this to anything valid, like "2a" for example. This isn't going to do anything, just activates the part of the code in default_filter.php file that does the sorting.

:blink:

I'm using version v1.3.9d and I see a few places that have $listing_sql .= ' order by '; but there is other things around them I'm afraid I mess up. I've attached a copy of my default_filter.php What should I be replacing? My line 113 in my version looks nothing like the above.

17 Nov 2011, 8:35 AM
#15
dmagic avatar

dmagic

Totally Zenned

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

Re: sort sub-category view by date added

I like if someone can help please .

ZEN 1.3.9.H

How can show first the new products added in category ?

Thanks