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.

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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


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.

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

I am no longer active at the Forum. Please do NOT send me Personal Mails,
they will no longer be replied to.
My Github OC Site: https://github.com/IP-CAM
4'100 + FREE OC Extensions, on the World's largest 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

ImageImageImageImage

For Friendly Professional Support - Click Here


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.

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.

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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by sedra » 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 25 guests