Page 1 of 1

Creating a default sort order for product

Posted: Wed Sep 28, 2011 10:33 pm
by doug3515
Hi there. The default is to do alpha asc. How do I sort price asc by default?

I see in category.tpl the listing for the products. If i did an asort that would only sort the names. Where is the SQL so I can sort appropriately.

Doug

Re: Creating a default sort order for product

Posted: Thu Sep 29, 2011 3:44 am
by grgr
Edit ../catalog/controller/product/category.php

Edit line 15 to read:

Code: Select all

			$sort = 'p.price';
Edit ..catalog/model/catalog/product.php

Edit line 127 to read:

Code: Select all

				$sql .= " ORDER BY p.price";	

[Resolved]Re: Creating a default sort order for product

Posted: Fri Sep 30, 2011 2:35 am
by doug3515
THANKS!

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 5:06 pm
by MatthewB
Hi

I can't find the $sql code on line 27?

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 5:16 pm
by SXGuy
MatthewB wrote:Hi

I can't find the $sql code on line 27?
127.

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 5:17 pm
by MatthewB
Sorry meant 127 haha, keyboard slip

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 6:10 pm
by grgr
MatthewB wrote:Sorry meant 127 haha, keyboard slip
The above is for 1.5.x which is why you probably can't find it.

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 6:35 pm
by MatthewB
No worries thanks, i'm running 1.5.1

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 7:21 pm
by grgr
MatthewB wrote:No worries thanks, i'm running 1.5.1
In which case just do a seach for:

Code: Select all

$sql .= " ORDER BY p.sort_order";
It should be the first occurance and inside this function:

Code: Select all

	public function getProducts($data = array()) {

Re: Creating a default sort order for product

Posted: Fri Oct 07, 2011 7:41 pm
by MatthewB
Still can't see it,

used ctrl+F and that doesn't find it either.