Guest Posted January 6, 2010 Share Posted January 6, 2010 Hi, we have a search facility in our site which lists the matching products at /catalog/advanced_search_result.php. It works fine except that it doesn't display the products listed according to price. Instead it seems to be by model number or something which makes it look quite random. What we want to do is have this page always display the products in order of price, with the lowest price first and working up. However I tried editing the mySQL query in advanced_search_result.php as follows: $sql .= "ORDER BY ".$cols[$match[1]].($match[2] == 'd' ? ' DESC' : ''); Change to: $sql .= "ORDER BY p.price"); But this causes all sorts of starnge issues such as not all the correct products displaying. Does anyone know how this can be done? I saw another thread relating to it but my version of /catalog/index.php (which it mentioned changing) was completely different. Link to comment Share on other sites More sharing options...
spooks Posted January 6, 2010 Share Posted January 6, 2010 There is a thread on setting default sort order here Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
Guest Posted January 6, 2010 Share Posted January 6, 2010 There is a thread on setting default sort order here yes, this is the one I mentioned- but I don't have that corresponding code in my catalog/index.php file. What I have in that area (around line 200) is: for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': #$select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': #$select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': #$select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': #$select_column_list .= 'p.products_weight, '; break; } } So unfortunately the thread doesn't explain how I can change the sort order... Link to comment Share on other sites More sharing options...
spooks Posted January 6, 2010 Share Posted January 6, 2010 Try looking harder, the section refered to is about 50 lines below that bit!! http://www.oscommerce.com/forums/index.php?showtopic=308798&hl= Please ask there if you need more, keeps answers in one place!! Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
Guest Posted January 6, 2010 Share Posted January 6, 2010 Try looking harder, the section refered to is about 50 lines below that bit!! http://www.oscommerce.com/forums/index.php?showtopic=308798&hl= Please ask there if you need more, keeps answers in one place!! Okay, well I changed those 2 lines to /catalog/index.php and uploaded- but when I do a search I get the same sort order, it isn't sorting by price... any ideas? Link to comment Share on other sites More sharing options...
Guest Posted January 7, 2010 Share Posted January 7, 2010 Okay, well I changed those 2 lines to /catalog/index.php and uploaded- but when I do a search I get the same sort order, it isn't sorting by price... any ideas? Anyone else got any ideas about this? The solution in the other thread doesn't work- and I can't seem to find a way of making search results order by price... Link to comment Share on other sites More sharing options...
spooks Posted January 7, 2010 Share Posted January 7, 2010 Anyone else got any ideas about this? The solution in the other thread doesn't work- and I can't seem to find a way of making search results order by price... I did reply to you there, but it looks like the forum may have lost those posts as you posted a reply mid-thread. See my post there for code for search results dated 18 november Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
CybrWzrd7 Posted January 20, 2012 Share Posted January 20, 2012 I just changed the following lines on advanced_search_result.php and it does exactly what I want it to: 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'; $order_str = ' order by pd.products_name; break; } } to: 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'; $order_str = ' order by final_price'; break; } } Link to comment Share on other sites More sharing options...
patrickluursema Posted January 22, 2012 Share Posted January 22, 2012 Great, work here too! Thank you. Regards, Patrick Luursema Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.