Post by labeshops » Wed Aug 17, 2011 12:39 am

Okay, this is one of those little tweaks I did easily in my old software that I just cannot figure out how to do in OC v1.5.1 :( Still trying to get used to how the code is broken up.

All I want to do is in the products list in admin instead of display products alphabetically by product name, I want them to show the last product I added on top by default - so an "order by id DESC" type thing. Cannot figure out how to do this/where to add it :(

Thanks.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by khurrum » Fri Nov 15, 2013 11:32 am

In the file admin/controller/catalog/product.php

Find the following code:

Code: Select all

	if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'pd.name';
		}

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'ASC';
		}
Replace with following code:

Code: Select all

if (isset($this->request->get['sort'])) {
 $sort = $this->request->get['sort'];
 } else {
 $sort = 'p.date_added';
 }

 if (isset($this->request->get['order'])) {
 $order = $this->request->get['order'];
 } else {
 $order = 'DESC';
 }
In the file admin/model/catalog/product.php add the red marked code

$sort_data = array(
'pd.name',
'p.model',
'p.price',
'p.quantity',
'p.status',
'p.sort_order',
'p.date_added' //add this column name
);

Newbie

Posts

Joined
Wed Oct 23, 2013 10:36 pm
Who is online

Users browsing this forum: No registered users and 19 guests