Full service web hosting, great prices and support. Starts at $1.99/month!
Results 1 to 10 of 10

Thread: Sort by price?

  1. #1

    Default Sort by price?

    I want to sort my category listing by price. I have deduced that it's not in product_listing_col.php, because I put sort by price ASC in the $pg_query, and ran the query string through PHPMyAdmin, and it returned empty set, but my page shows products, so I know that the query must be passed from somewhere else but I don't know where.

    I see in index.php that there are references to $HTTP_GET_VARS and whether sort by price has been 'requested' and I think I remember this in the Admin of another OSC version, and I don't know how to pass the variables to index.php to make the categories list sort by price.

    Any tips appreciated.


  2. #2

    Default RE: Sort by price?

    I found that appending &sort=3a to my URL, like index.php?cPath=1_17&sort=3a
    does what I want. Now, how to get that appended onto the URL produced by clicking on the category in the categories box or from the categories list?

  3. #3


    I am having the same issue. Any luck?

  4. #4

  5. #5

    Default Re: Sort by price?

    Sorry to bump this but I thought it would be a good addition to the thread.

    To sort by lowest first you would use ?sort=3a, to sort by highest to lowest it's ?sort=3d.

    IF you want to do this in your product listings, apply the following examples. I'm running RC3 using product listing columns (product_listing_col.php).

    You may style these links however you see fit.

    PHP Code:
    $myfile $myfile[0];
    <a href="http://www.foo.bar/catalog/<?=(!empty($myfile)) ? $myfile ''?>?sort=3a">lowest price</a>
    <br />
    <a href="http://www.foo.bar/catalog/<?=(!empty($myfile)) ? $myfile ''?>?sort=3d">highest price</a>
    If you're a php guru feel free to make it better and let others know about it. I had a very good need for this function and came up with this, use it as you wish.

    Hope it helps someone..


  6. #6

    Default Re: Sort by price?

    I used this code on index_products.tpl right after the normal category sort at about line 60

     // Additional Products Sort
    	     echo '<td align="center" class="main">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . '<b>Sort by:</b>&nbsp;&nbsp;';
    	     if (isset($HTTP_GET_VARS['manufacturers_id'])) {
    	         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
    	     } else {
    	         echo tep_draw_hidden_field('cPath', $cPath);
    	     $sort_list = array('' => 'Select',
    							'4a' => 'Price Low to High',
    	                        '4d' => 'Price High to Low',
    							'3a' => 'Products Name A to Z',
    	                        '3d' => 'Products Name Z to A');
    	     foreach($sort_list as $id=>$text) {
    	      $sort_range[] = array('id' => $id, 'text' => $text);
    	     echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');
    	     echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));
    	     echo '</form></td>' . "\n";
     // End Additional Products Sort

  7. #7

    Default Re: Sort by price?

    Beautiful job again! Any one got any ideas on adding a sort by stock count? to this list?


    I think I got it - use 6a and 6d - enjoy!
    Last edited by blackhawk; 10-19-2009 at 11:23 AM.

  8. #8

    Default Re: Sort by price?

    the proposed solution doesn't work with v2.0.25!

    Any help on that?



  9. #9
    osCMax Development Team

    Sort by price?

    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    ridexbuilder     $ 15.00
    Rep Power

    Lightbulb Re: Sort by price?

    Quote Originally Posted by TBTB View Post
    the proposed solution doesn't work with v2.0.25!

    Any help on that?


    See: http://www.oscmax.com/forums/oscmax-...reference.html

    Developers resource at bitbucket
    *** *** ***
    oscmax.co.uk / ejsolutions.co.uk
    Hosting plans with installation, configuration, contributions, support and maintenance.
    *** FREE osCmax hosting available ***

  10. #10

    Default Re: Sort by price?

    Hi I am a novice using V2.0.25 but found a post that suggested changing the following highlighted code in /catalog/index.php from

    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";

    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 p.products_price";

    This defaults products to price order when you click on a category to display the products within. This worked for me.

    I am not sure this is a complete fix now! This seems to work when expanding the products within a category. However once the products are displayed, if you have more than one manufacturer and then filter by use the displayed "Show:" by manufacturer name, the resultant product list loses its order again. There was also an old post for v1.7 that seemed to indicate that with more than one page of products in a category, every other page displayed was out of price order. This may be related to the same thing???

    Any help out there??? I would prefer not to have to add some large sort contribution for what I suspect is a minor change to the expert.
    Last edited by emty; 09-14-2010 at 02:01 AM. Reason: Partly resolved but found further related issue??

Similar Threads

  1. Separate Price per customer additional price box
    By auntie22 in forum osCmax v1.7 Discussion
    Replies: 0
    Last Post: 06-05-2006, 08:12 AM
  2. attribute sort
    By timbrrr in forum osCmax v2 Customization/Mods
    Replies: 3
    Last Post: 01-17-2006, 12:24 PM
  3. Sort by price question
    By moreduff in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 08-02-2005, 07:32 AM
  4. Sort products by price
    By Anonymous in forum osCmax v1.7 Discussion
    Replies: 3
    Last Post: 06-02-2005, 04:55 AM
  5. Add Delivery Price based on Total Price
    By mikeyboy in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 01-30-2004, 09:24 AM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts