PDA

View Full Version : product list sorting


Andy
04-05-07, 01:05
Is it possible to get the api to show the product list sorted by price lo-hi by default?

Ive tried alsorts and the best i could do was to get the drop down box to show lo-hi by default, but the results are still by popularity.

tearing my hair out on this one!!

authcode
04-05-07, 09:36
Are you coding with the API or is this with the client install? If you're coding it yourself you just need to set the sSort parameter to "lo" when you call getProductList.

Andy
04-05-07, 12:38
I've sussed it.

Its abit of a hack, but it works.

in category.php (its the full api btw), just above:
$oPage = new pageCategory($_GET['sListSort'], $_GET['iListLimit'], $_GET['iListOffset']);
above it I added:
if(!isset($_GET['sListSort']) ){
$_GET['sListSort'] = "lo";
}

For the less codey inclined, all that does is check that the list is already sorted. IF the List isn't set (!isset) then set list to Low-High (lo).

sspyrou
29-01-09, 23:51
Hi Andy

I need to do exactly the same in reverse (i.e. sort hi to lo) in version 2 and can't seem to get any chnage in teh sort order.

Could you confirm which file i should be working on?

I've been trying to add

$_GET['sListSort'] = 'hi';

into product_display.php, and a few other files with no joy..

could yould point me in the right direction?

Thanks
Soot

sspyrou
30-01-09, 00:09
i've also tried editing the line

var $sSort = 'popularity'; // one of [az, za, hi, lo, popularity]

in class.api_product_list.php with no joy..
im at a loss on this - can it be changed or is sort type set in stone?

Andy
30-01-09, 12:52
product_display.php is for a single product display, you can't order one product by anything.

If you meant product_display_list.php, then it is too far into the execution of things, try adding it above require_once('constants.inc.php'); in productlist.php

once you get to product_display_list.php, everything has been requested and responded to.

*edit*
I'd also avoid changing anything in any of the class.xxxxxx.php files in V2. The boys have created a very flexible core so there really isn't much need to mess with them. Any changes can be made away from these files with much the same success

Iarna
30-01-09, 22:37
class.api_product_list.php
This Line:
var $sSort = 'popularity'; // one of [az, za, hi, lo, popularity]
To This
var $sSort = 'hi'; // one of [az, za, hi, lo, popularity]
Works.