how to display latest uploaded products first in category page in opencart

165
February 20, 2019, at 7:20 PM

Can anyone tell me how to change the display order on the category page in opencart? My products are being displayed in reverse chronological order (oldest products first) and I would like newest products to display first. I have read several posts but cannot find a good answer. I'm sure it's something simple but I cannot figure it out.

Any help is greatly appreciated.

i tried below code but not get any result.

Default sortorder is: p.sort_order ASC

Edit catalog/controller/product/category.php.

Find:

$sort = 'p.sort_order';

Change into:

$sort = 'p.date_added';

Again Find:

$order = 'ASC';

Change into:

$order = 'DESC';

To set it as default sorting: Change:

'value' => 'p.sort_order-ASC',

Into:

'value' => 'p.date_added-DESC',

Here i can't get any result after change like this. I tried so many times but not found. Can any one please help me on this Opencart category page.

Answer 1

Provide the query code please.

But i think you want something like this:

SELECT * FROM (your table name) ORDER BY id ASC;

it's simple as that. This query will display the newest created products.

Rent Charter Buses Company
READ ALSO
php server side reCAPTCHA

php server side reCAPTCHA

I have a php code that sends a emailI am trying to change it so that it send the email if the reCAPTCHA is set to true if false go back to page

155
“Could not resolve host” error with curl_multi on cURL version 7.64

“Could not resolve host” error with curl_multi on cURL version 7.64

I'm getting "Could not resolve host" when I call curl_error($ch) in curl_multi context, the errno is 0 though, and the request is done successfully also(I'm getting the expected response from the remote server)

146
Null values inserted in database table using php pdo

Null values inserted in database table using php pdo

I made a PHP interface for teacher tableAll columns in table is set to NOT NULL

178