Page 1 of 1

Sort by model on front end?

Posted: Wed Nov 07, 2018 12:42 am
by postidol
Hey all,

My client has asked to have their products sorted by model number on the front end of the website. Anyone know how I could tackle this?

Thank you in advance! :)

Re: Sort by model on front end?

Posted: Wed Nov 07, 2018 1:23 am
by cyclops12
You can choose to sort by model in the dropdown box in category pages

Re: Sort by model on front end?

Posted: Thu Nov 08, 2018 11:54 am
by postidol
Hi there. Thanks for the reply. Yes, that's true. But how can I make that the default sort order?

Re: Sort by model on front end?

Posted: Thu Nov 08, 2018 1:36 pm
by ocmta
In catalog/controller/product/category.php, find this code, it's near the top of the file:

Code: Select all

if (isset($this->request->get['sort'])) {
	$sort = $this->request->get['sort'];
} else {
	$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
	$order = $this->request->get['order'];
} else {
	$order = 'ASC';
}
And replace

Code: Select all

$sort = 'p.sort_order';
with

Code: Select all

$sort = 'p.model';
If you want default order to be descending (from Z to A), replace

Code: Select all

$order = 'ASC';
with

Code: Select all

$order = 'DESC';
Then you can do the same for manufacturer.php, search.php and special.php in catalog/controller/product . Then if you use any modifications, refresh them in admin.

Re: Sort by model on front end?

Posted: Fri Nov 09, 2018 12:00 am
by postidol
OMG! Thank you so much for your help. I really appreciate it!!!! Thank you, thank you! You're awesome!!!