Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1

    Default Change sort order- Show In Stock items first

    Hi, is there any way i can change the sort order for all my products in each category so that the in stock items are shown first and out of stock will be on the last pages of each category?
    I know i will probably have to change code somewhere, i just dont know where?!
    thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Change sort order- Show In Stock items first

    All I can tell you to begin with is that you would have to do quite a bit of modification for this in the file includes\index_filters\default_filter.php
    Tutorials on Zen Cart
    http://tutorials.zen-cart.com/index.php
    ---------------
    advanced.programmer at gmail dot com
    In love with Zen Cart!!

  3. #3

    Default Re: Change sort order- Show In Stock items first

    i thought i would have to do some modifications, that wouldnt be a problem. Do you know what i would have to modify/change?
    Thanks.

  4. #4

    Default Re: Change sort order- Show In Stock items first

    i have found how to sort it by stock items. As i set my stock levels by using the products quantity field, and putting 100 for in stock, and 0 for out of stock, i changed this code:


    // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER ia left blank
    // for reverse, descending order use:
    // $listing_sql .= " order by p.products_sort_order desc , pd.products_name";
    $listing_sql .= " order by p.products_sort_order , pd.products_name";
    break;
    }
    }

    to:


    // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER ia left blank
    // for reverse, descending order use:
    // $listing_sql .= " order by p.products_sort_order desc , p.products_quantity";
    $listing_sql .= " order by p.products_sort_order , p.products_quantity";
    break;
    }
    }



    This worked great, but the only problem is, its sorting them with out of stock first, and in stock last!!!!

    Any ideas how i would get it to swap around?
    Thanks.

  5. #5

    Default Re: Change sort order- Show In Stock items first

    Ok, i have managed to get it right. For anybody else who would like to know:

    You have to modify includes/index_filters/default_filter.php

    Go to line 108 and change:

    $listing_sql .= " order by p.products_sort_order , pd.products_name";

    to

    $listing_sql .= " order by p.products_sort_order , p.products_quantity desc";

    This will sort the order showing in stock items first, and out of stock items last.

  6. #6
    Join Date
    Jan 2009
    Location
    chicago
    Posts
    1
    Plugin Contributions
    0

    Default Re: Change sort order- Show In Stock items first

    I had to change line 57 and 63 in my old version 2.67

  7. #7
    Join Date
    Jan 2009
    Posts
    14
    Plugin Contributions
    0

    Default Re: Change sort order- Show In Stock items first

    Has anyone got this working in newer versions of zen cart?
    Cheers!

  8. #8
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Change sort order- Show In Stock items first

    Can't seem to get this to work with version 1.3.8a

    Can anyone help?

  9. #9
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Change sort order- Show In Stock items first

    Anyone?

  10. #10
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Change sort order- Show In Stock items first

    I've tried changing this code

    $_GET['sort'] = $i+1 . 'a';

    $listing_sql .= " order by p.products_sort_order, pd.products_name";

    break;

    but nothing changes, when I search for something, the out of stocks aren't moved to the bottom, what am I doing wrong?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Show out of stock items last
    By matchlock in forum Setting Up Categories, Products, Attributes
    Replies: 15
    Last Post: 8 Apr 2013, 05:25 PM
  2. Want items to show out of stock after 5 items left
    By rickiesdiscount in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 21 Oct 2008, 02:54 AM
  3. Sort Order - All - sort by a-z (show a - c, etc)
    By kiermasz in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 4 Jun 2008, 09:43 PM
  4. Show newest items first
    By Moncia in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 8 Apr 2007, 06:45 PM

Posting Permissions

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