Post by Axel Wers » Wed Feb 21, 2018 5:49 am

Default sorting by name is useless. I need the newest products on the top.

I edited file admin/controller/catalog/product.php

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';
to

Code: Select all

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

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'DESC';
But without any effect, products are still sorted by name. Weird.

What is wrong?

The same I need for front-end.

Thanks.

OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm

Post by straightlight » Wed Feb 21, 2018 6:41 am

No OC version posted, no file attachment posted with provided issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Axel Wers » Wed Feb 21, 2018 6:49 am

The latest, 3.0.2.0, of course.

OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm

Post by IP_CAM » Wed Feb 21, 2018 1:42 pm

Well, that's not the latest anymore... :laugh:
Better always talk facts and figures, in a tech place like this. ;)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by uksitebuilder » Wed Feb 21, 2018 4:22 pm

Have a look at line ~392 in admin/model/catalog/product.php too

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Axel Wers » Wed Feb 21, 2018 4:23 pm

Officially, version 3.0.2.0 is still the latest version.

OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm

Post by Axel Wers » Wed Feb 21, 2018 4:39 pm

uksitebuilder wrote:
Wed Feb 21, 2018 4:22 pm
Have a look at line ~392 in admin/model/catalog/product.php too
Yes, on 423 row the same, I changed it but without effect.

OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm

Post by straightlight » Wed Feb 21, 2018 6:29 pm

After making each changes, ensure to clear your OC cache from the admin - > dashboard - > blue square icon and from your admin - > extensions - > modifications - > refresh button.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by aerogel » Wed Aug 21, 2019 1:08 am

straightlight wrote:
Wed Feb 21, 2018 6:29 pm
After making each changes, ensure to clear your OC cache from the admin - > dashboard - > blue square icon and from your admin - > extensions - > modifications - > refresh button.
thank you very much.
this piece of code

Code: Select all

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

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'DESC';
didn't work until i refreshed modifications.
saved me some 2 hours!

New member

Posts

Joined
Thu Jan 04, 2018 8:14 pm

Post by letxobnav » Wed Aug 21, 2019 10:27 am

if you want to sort on p.product_id you have to add the p.product_id to the sort eligible array in the getproducts function:

Code: Select all

		$sort_data = array(
			'pd.name',
			'p.model',
			'p.quantity',
			'p.price',
			'rating',
			'p.sort_order',
			'p.date_added'
		);
add p.product_id to that list

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 398 guests