View Full Version : product list sorting
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!!
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.
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).
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
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?
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
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.