Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Nov 2006
    Posts
    512
    Plugin Contributions
    0

    Default Different Sort Order for Search Results than Product Listing

    How would I go about changing the sort order on the search results page while keeping the product listings in its original order.

    example: Have the product listings sort by product name and have the search results sort by price:

    as set in the admin:

    Config>Product Listing> Display Product Listing Default Sort Order> 2a

    But wish to have search results display 5d
    Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

  2. #2
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Different Sort Order for Search Results than Product Listing

    The search results listing is generated using the script found in includes/modules/pages/advanced_search_result/header_php.php. The actual order is decided by the script on lines 385 - 431. If you wish to override it, place your order script on line 432. Alternatively, copy the variable PRODUCT_LISTING_DEFAULT_SORT_ORDER within your database configuration table, and then insert it into your configuration table again, using a different name. Then simply replace the constant found within this script with the new constant you just created, and you're done!

    Absolute

  3. #3
    Join Date
    Nov 2006
    Posts
    512
    Plugin Contributions
    0

    Default Re: Different Sort Order for Search Results than Product Listing

    PHP Code:
      // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
      
    if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
        
    $_GET['sort'] = '20a';
      }
    } else {
      
    $sort_col substr($_GET['sort'], 1);
      
    $sort_order substr($_GET['sort'], 1);
      
    $order_str ' order by ';
      switch (
    $column_list[$sort_col-1]) {
        case 
    'PRODUCT_LIST_MODEL':
        
    $order_str .= "p.products_model " . ($sort_order == 'd' "desc" "") . ", pd.products_name";
        break;
        case 
    'PRODUCT_LIST_NAME':
        
    $order_str .= "pd.products_name " . ($sort_order == 'd' "desc" "");
        break;
        case 
    'PRODUCT_LIST_MANUFACTURER':
        
    $order_str .= "m.manufacturers_name " . ($sort_order == 'd' "desc" "") . ", pd.products_name";
        break;
        case 
    'PRODUCT_LIST_QUANTITY':
        
    $order_str .= "p.products_quantity " . ($sort_order == 'd' "desc" "") . ", pd.products_name";
        break;
        case 
    'PRODUCT_LIST_IMAGE':
        
    $order_str .= "pd.products_name";
        break;
        case 
    'PRODUCT_LIST_WEIGHT':
        
    $order_str .= "p.products_weight " . ($sort_order == 'd' "desc" "") . ", pd.products_name";
        break;
        case 
    'PRODUCT_LIST_PRICE':
        
    //        $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        
    $order_str .= "p.products_price_sorter " . ($sort_order == 'd' "desc" "") . ", pd.products_name";
        break;
      }

    Thanks for your post, Im more comfortable with editing php files than the db, what line would I change above to get the search results to sort by price (instead of Name which is what is set in the admin for product listings) ?

    current URL for results:
    Code:
    index.php?main_page=advanced_search_result&search_in_description=1&keyword=KEYWORD
    need somewhere in there:
    Code:
    &sort=5d
    Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

  4. #4
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Different Sort Order for Search Results than Product Listing

    Updating the database is easier than the PHP to be honest. You just need to copy the one record, and that will correct the whole thing. You would also need to update that constant within the header file.

    Go on - have a go, and if you need help, just ask! Honestly, you'll be fine!

    Absolute

 

 

Similar Threads

  1. v150 Custom search results display different from Product Listing
    By QuovisCreative in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 27 Aug 2012, 09:08 PM
  2. Show Product Listing only for search results
    By Matthew1246 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 2 Nov 2011, 03:56 AM
  3. Column Layout Grid for Product Listing > Sort order bug
    By edwardtilbury in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 14 Mar 2009, 04:59 AM
  4. Replies: 8
    Last Post: 5 Dec 2006, 10:52 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