Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Posts
    29
    Plugin Contributions
    0

    red flag How does &sort= work?

    I have set up a sort box in the product listing pages to add the &sort= , When I sort by price 3d or 3a it works fine. I set up some custom fields in the product table and added them to the sort box (eg 8a, 9) following the existing format.

    The new &sort=x is displaying fine in the url string, and I changed the default filter to have new case statements (keeping the format of the existing ones)

    case 'PRODUCT_LIST_WEIGHT':
    $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
    break;

    case 'PRODUCT_LIST_NEWVAR':
    $listing_sql .= "p.products_newvar" . ($sort_order == 'd' ? 'desc' : '');
    break;

    but the box defaults back to -reset- and the products are not sorted.

    My custom fields display fine on the products page in the listings themselves, and I added the new fields to pretty much every sql select statement I could find in the includes directory. but still no sorting.

    Where is the &sort= parsed and order by created if not in the default filter file? I have to think, I need to change something in the defaultfilter file ... maybe around:

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

    I have this working for my all / new / featured products, but I know that uses a different sorting technique ( this is why I changed the search box to amend the url string)

    Any input is appreciated!

  2. #2
    Join Date
    Oct 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: How does &sort= work?

    HELP!

    I think I've figured out my problem. I JUST DON'T KNOW HOW TO FIX IT!

    I've added a drop down sorter to the Category Listing(tpl_index_product_list.php) and the Advanced Search Results page(tpl_advanced_search_result_default.php).

    When I select a Sort Order in the drop down sorter, it seems to work... it produces the correct URL and changes the "select" in the drop down sorter, HOWEVER, it doesn't sort the products listed (they keep the same sort order).

    I THINK the problem is this piece of code that is found in BOTH the default_filter.php AND in the header_php.php for the Advanced Search Page...
    PHP Code:
    // set the default sort order setting from the Admin when not defined by customer
      
    if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
        
    $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
      }

      if (isset(
    $column_list)) {
        if ((!isset(
    $_GET['sort'])) || (isset($_GET['sort']) && !ereg('[1-8][ad]'$_GET['sort'])) || (substr($_GET['sort'], 01) > sizeof($column_list)) ) {
          for (
    $i=0$n=sizeof($column_list); $i<$n$i++) {
            if (isset(
    $column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') {
              
    $_GET['sort'] = $i+'a';
              
    $listing_sql .= " order by p.products_sort_order, pd.products_name";
              break;
            } else {
    // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is 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;
            }
          }
    // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
          
    if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
            
    $_GET['sort'] = '20a'
    And more specificly, this line of code:
    PHP Code:
    $listing_sql .= " order by p.products_sort_order, pd.products_name"
    The sort ALWAYS reverts back to what is listed in this code for some reason. I've tried several ways to just remove it, but I always get errors.

    Is there a way that this code can be adjusted so that the sort order doesn't default to what is listed in that code?

 

 

Similar Threads

  1. Replies: 27
    Last Post: 22 Feb 2015, 07:25 PM
  2. v150 Custom Sort Order does not work
    By DeepGirl in forum Setting Up Categories, Products, Attributes
    Replies: 8
    Last Post: 6 Jun 2014, 04:22 PM
  3. does standard zencart work with Mobile & Smart Phones?
    By Ms_X in forum General Questions
    Replies: 2
    Last Post: 20 Jan 2011, 01:09 PM
  4. Expected Sort order does not work
    By PeterBKK in forum General Questions
    Replies: 9
    Last Post: 25 Apr 2008, 10:46 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