Forums / Setting Up Categories, Products, Attributes / Newest product first - sort product by date

Newest product first - sort product by date

Started by jeet_kune_do on 22 Jan 2010, 4:03 PM · Views: 3,703

Results 1 to 12 of 12
22 Jan 2010, 4:03 PM
#1
jeet_kune_do avatar

jeet_kune_do

Zen Follower

Join Date:
Nov 2008
Location:
Slovenija
Posts:
119
Plugin Contributions:
0

Newest product first - sort product by date

I would like that my products is sorted by date. The newest product should appear first.

Did you have some suggestions?

I love internet and the power of information... Best Wishes!!

22 Jan 2010, 4:13 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Newest product first - sort product by date

Your options are at

admin > config > layout settings > Categories/Products Display Sort Order

Zen-Venom Get Bitten

24 Jan 2010, 5:00 PM
#3
jeet_kune_do avatar

jeet_kune_do

Zen Follower

Join Date:
Nov 2008
Location:
Slovenija
Posts:
119
Plugin Contributions:
0

Re: Newest product first - sort product by date

There isn't any option to sort by date, only by name, quantity and price.

I love internet and the power of information... Best Wishes!!

25 Jan 2010, 3:07 AM
#4
jamielife avatar

jamielife

Zen Follower

Join Date:
Dec 2009
Location:
Richmond, VA
Posts:
161
Plugin Contributions:
0

Re: Newest product first - sort product by date

I would like to do this too, my products seem to do what they want... sometimes its by sort order, sometimes not. Date added would be much nicer.

7 Dec 2010, 4:26 PM
#5
sharontan avatar

sharontan

New Zenner

Join Date:
Nov 2010
Posts:
57
Plugin Contributions:
0

Re: Newest product first - sort product by date

Hey, so what's the answer? How to sort by date? NEed help too..

7 Dec 2010, 5:07 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Newest product first - sort product by date

There are a number of places where the Products are listed ...

Could you give more details on where you are trying to get Products listed by date? :unsure:

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!

24 Dec 2010, 9:44 AM
#7
schumi avatar

schumi

New Zenner

Join Date:
Mar 2009
Location:
Shenzhen
Posts:
10
Plugin Contributions:
0

Re: Newest product first - sort product by date

Ajeh:

There are a number of places where the Products are listed ...

Could you give more details on where you are trying to get Products listed by date? :unsure:

Hello Ajeh,

I just want them sorted by date added in the search results any time, how should i do?

Thanks very much.

--Schumi

24 Dec 2010, 5:01 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Newest product first - sort product by date

You would need to change the:
$order_str

in the file:
/includes/modules/pages/advanced_search_results/header_php.php

most likely around line 454:

$listing_sql = $select_str . $from_str . $where_str . $order_str;

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!

25 Dec 2010, 8:17 AM
#9
schumi avatar

schumi

New Zenner

Join Date:
Mar 2009
Location:
Shenzhen
Posts:
10
Plugin Contributions:
0

Re: Newest product first - sort product by date

Ajeh:

You would need to change the:
$order_str

in the file:
/includes/modules/pages/advanced_search_results/header_php.php

most likely around line 454:

$listing_sql = $select_str . $from_str . $where_str . $order_str;


Thanks the reply.

I found out the code in header_php.php, but i don't know where to put the code or change the $order_str with "p.products_date_added"

I try to put it everywhere but then error happened :blush:

Please check the code there:

// if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
$_GET['sort'] = '20a';
}
} else {
$sort_col = substr($_GET['sort'], 0 , 1);
$sort_order = substr($_GET['sort'], 1);
$order_str = ' order by ';
switch ($column_list[$sort_col-1]) {
case 'PRODUCT_LIST_MODEL':
$order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
break;
case 'PRODUCT_LIST_NAME':
$order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");
break;
case 'PRODUCT_LIST_MANUFACTURER':
$order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
break;
case 'PRODUCT_LIST_QUANTITY':
$order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
break;
case 'PRODUCT_LIST_IMAGE':
$order_str .= "pd.products_name";
break;
case 'PRODUCT_LIST_WEIGHT':
$order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
break;
case 'PRODUCT_LIST_PRICE':
// $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
$order_str .= "p.products_price_sorter " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
break;
}
}

$listing_sql = $select_str . $from_str . $where_str . $order_str;
// Notifier Point
$zco_notifier->notify('NOTIFY_SEARCH_ORDERBY_STRING', $listing_sql);


Could you help me?

Have a nice christmas!
--Schumi
25 Dec 2010, 2:39 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Newest product first - sort product by date

The sort order is defined by the contents of the:
$order_str

If you want the display order to be different than any of the existing sort orders, you can change its content before that line so it contains an ORDER BY statement to match your needs ...

Something like adding the line in red:

$order_str = " ORDER BY p.products_date_added DESC, pd.products_name ";
$listing_sql = $select_str . $from_str . $where_str . $order_str;

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!

16 Jan 2011, 9:45 PM
#11
addaboo avatar

addaboo

New Zenner

Join Date:
Jan 2011
Posts:
1
Plugin Contributions:
0

Re: Newest product first - sort product by date

Hello! Thanks for the info - I successfully implemented on the Advanced Search results page. Very cool!

How could I go about sorting all products on the product index display page by newest added? example: when users click a category (with no subcategories) and see all my products sorted by name, or price, or quantity (as set in "Config > Layout Settings > Categories/Products Display Sort Order")... I would like to have them sorted by date added instead - being newest first listed at the top?

What page should be modified? I hunted around in "includes > modules > product_listing.php" but can't really understand it...

Help anyone?
Thanks in advance - this is really important for my store.
Ada

16 Jan 2011, 10:33 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Newest product first - sort product by date

The Product Listing when navigating the Categories does not, by default, have a choice for products_date_added ...

Again, the code would need to be customized for this ...

You would have to make similar customization to the:
/includes/index_filters/default_filter.php

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!