Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product sort


Twice_knightly

Recommended Posts

Hello,

 

Is there an easy way to just display products in order of price? All the contributions I've seen look like they give you the ability to set the sort order, this is a bit over complicated for me as I just wish to sort by price alone.

 

Hope you can help, thanks.

Cheers

Carl.

Link to comment
Share on other sites

Hey Carl, this ought to be a piece of cake, as the functionality is included in the standard osc package. If you click on price when you are viewing the product list within a category, it will sort them ascending, click on it again and it will sort by descending price. There ought to be a bit of code that sets the default sort method in index.php

 

I think this is it:

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
     for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
       if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by pd.products_name";
         break;

 

If you changed it so that it read order by pd.products_price"; right near the ned there, that might do the trick. Remember, always backup a file before you start messing with it, so you have something to restore it back to if it doesn't work out! I usually download the file from the server, then change the filename on the server to filenameorig.php before changing any code. Then I modify the file and upload it as filename.php. That way a known good copy is right there, on the server, and all it takes to go back is to delete my modified filename.php file, and rename the original file by taking out the orig.

 

Jeremy

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...