Bryan Posted October 22, 2002 Share Posted October 22, 2002 I'd like to list my products from the highest price on down on the product display pages of each category. I see from the query string that 'sort=3d' is appended. Where can I add that so that the categories all have that appended as a default? Link to comment Share on other sites More sharing options...
Bryan Posted October 23, 2002 Author Share Posted October 23, 2002 Anyone? Link to comment Share on other sites More sharing options...
Ajeh Posted October 23, 2002 Share Posted October 23, 2002 Well, you know you can click the titles to change the sort order to which ever order you want on the product listing. What you need to do is change the default order that is being used. Something like this in the start of default.php works: if ( !$HTTP_GET_VARS['sort'] ) { $HTTP_GET_VARS['sort'] = '4d'; $sort_order='d'; } Link to comment Share on other sites More sharing options...
gevans Posted October 23, 2002 Share Posted October 23, 2002 I just took this bit of code in default.php starting on line 210: if ( (!$HTTP_GET_VARS['sort']) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'],0,1) > sizeof($column_list)) ) { for ($col=0; $col<sizeof($column_list); $col++) { if ($column_list[$col] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $col+1 . 'a'; $listing_sql .= " order by pd.products_name"; break; and changed the fourth and sixth lines to what I want it to sort by. Price sort example below: if ( (!$HTTP_GET_VARS['sort']) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'],0,1) > sizeof($column_list)) ) { for ($col=0; $col<sizeof($column_list); $col++) { if ($column_list[$col] == 'PRODUCT_LIST_PRICE') { $HTTP_GET_VARS['sort'] = $col+1 . 'a'; $listing_sql .= " order by final_price"; break; Link to comment Share on other sites More sharing options...
Bryan Posted October 28, 2002 Author Share Posted October 28, 2002 gevans, I did what you did but added a 'desc' in the query as I wanted the most expensive on down. Now, while on that page the price column defaults to "Price +" which if you click on that it just shows the same page:) How can I get it so that is shows "Price -" and the link goes to 'a' and not 'd'? This way they can sort from least expensive to most expensive without having to click that link twice:) Link to comment Share on other sites More sharing options...
Ajeh Posted October 28, 2002 Share Posted October 28, 2002 The method I posted starts you in descending and first click switches to ascending if that helps. Link to comment Share on other sites More sharing options...
Guest Posted December 19, 2002 Share Posted December 19, 2002 Bryan, Where/How did you add the desc to the query? Thanks in advance. Laura Link to comment Share on other sites More sharing options...
pdh Posted January 5, 2003 Share Posted January 5, 2003 Well, you know you can click the titles to change the sort order to which ever order you want on the product listing. What you need to do is change the default order that is being used. Something like this in the start of default.php works: if ( !$HTTP_GET_VARS['sort'] ) { $HTTP_GET_VARS['sort'] = '4d'; $sort_order='d'; } Linda I tried this in my store as I want to sort everything by price descending but it seems to do nothing. Did something change in Nov 2.2 snapshot. Link to comment Share on other sites More sharing options...
Ajeh Posted January 5, 2003 Share Posted January 5, 2003 Place an echo in your file for $HTTP_GET_VARS['sort'] and then click on the title of the method you want to use and see what the results are. Mine was 4d your's could be 2d ... :shock: Link to comment Share on other sites More sharing options...
pdh Posted January 5, 2003 Share Posted January 5, 2003 cracked it - down to me being stupid. Thanks. Link to comment Share on other sites More sharing options...
Ajeh Posted January 5, 2003 Share Posted January 5, 2003 How stupid were you ... so ... like ... umm ... I can avoid doing the same thing ... :D Link to comment Share on other sites More sharing options...
pdh Posted January 7, 2003 Share Posted January 7, 2003 I modified my test site - l wouldn't want to mess the live one up - then looked at the live site and couldn't figure why it wouldn't work. Doh !! :oops: Link to comment Share on other sites More sharing options...
Ajeh Posted January 8, 2003 Share Posted January 8, 2003 Makes me feel better for the multiple times I have done something brilliant like that ... 8) Link to comment Share on other sites More sharing options...
Mark Russell Posted January 8, 2003 Share Posted January 8, 2003 Anyone know of a way (or a contribution) to allow sorting of products similar to sorting of categories, where you could enter the sort order in the product description and sort them anyway you wish with number entries (e.g. 1, 2, 3, etc.)? Seems like a pretty big hack. Thanks, Mark Link to comment Share on other sites More sharing options...
Bryan Posted January 29, 2003 Author Share Posted January 29, 2003 Laura, I was able to get the desired results by changing the code in default.php to: if ( (!$HTTP_GET_VARS['sort']) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'],0,1) > sizeof($column_list)) ) { for ($col=0; $col<sizeof($column_list); $col++) { if ($column_list[$col] == 'PRODUCT_LIST_PRICE') { $HTTP_GET_VARS['sort'] = $col+1 . '3a'; $listing_sql .= " order by final_price desc"; break; } } This now lists products from the highest price on down the sort column at the top will show Price- for those that want to reverse the sort and change the display to least expensive on down. Link to comment Share on other sites More sharing options...
Mark Russell Posted January 29, 2003 Share Posted January 29, 2003 Anyone know of a way (or a contribution) to allow sorting of products similar to sorting of categories, where you could enter the sort order in the product description and sort them anyway you wish with number entries (e.g. 1, 2, 3, etc.)? Seems like a pretty big hack. Thanks, Mark I asked the above about three weeks and since put together a contribution to do this. Anyone that is interested in having product sort capability similar to category sort, you can find the contribution here: http://www.oscommerce.com/community/contributions,911 Mark Link to comment Share on other sites More sharing options...
Guest Posted January 31, 2003 Share Posted January 31, 2003 I found Linda's example to be just the bit i needed as i also wanted to start from most expensive down to cheapest. I found a slight snag... When i clicked the "Next" button it altomaticly reverted back to cheapest first... LOL, got a big ticking off from my client for that. I noticed that the "next" button was creating an extra "3". So "3d" would become "33d" on the "next" button click. All I did was remove the "3" from the "3d" it worked fine. I am not sure where the "3" comes from but it worked for me. My client is happy now and I am a happy bunny again. Link to comment Share on other sites More sharing options...
Guest Posted April 10, 2003 Share Posted April 10, 2003 (Been awhile since I posted in this thread), but I wanted to thank both Duncan & Bryan for the solution to the sort order. I needed both tips and they worked like a charm...Thank you! Laura Link to comment Share on other sites More sharing options...
BoulderDash Posted January 20, 2004 Share Posted January 20, 2004 Hey there, I've looked everywhere for the "default.php" file so that I can sort Most Expensive to Least Expensive and cannot find it :unsure: . Is there any chance someone could Post the path? Thanks in advance, BD osC 2.2 m2 Link to comment Share on other sites More sharing options...
damsbo Posted May 23, 2005 Share Posted May 23, 2005 Hey there,I've looked everywhere for the "default.php" file so that I can sort Most Expensive to Least Expensive and cannot find it :unsure: . Is there any chance someone could Post the path? Thanks in advance, BD osC 2.2 m2 <{POST_SNAPBACK}> Like me (and others, you are now looking for "index.php" Still trying (no luck) to creack this one for 2.2ms2 AND the price break contrib. Any luck since this post? damsbo Link to comment Share on other sites More sharing options...
damsbo Posted May 23, 2005 Share Posted May 23, 2005 Hey there,I've looked everywhere for the "default.php" file so that I can sort Most Expensive to Least Expensive and cannot find it :unsure: . Is there any chance someone could Post the path? Thanks in advance, BD osC 2.2 m2 <{POST_SNAPBACK}> Boulder et.al. Got it! In index.php find the following if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by pd.products_name"; I've changed in first line _NAME to _MODEL and in third line pd.products_name to p.products_model Wonder if this wouldnt work for PRICE too?? BACK-UP, then give it a try :-) damsbo Link to comment Share on other sites More sharing options...
technigrafa Posted June 23, 2005 Share Posted June 23, 2005 In index.php find the following if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by pd.products_name"; I've changed in first line _NAME to _MODEL and in third line pd.products_name to p.products_model I am trying to sort descending by product name and I have tried to chane the above 'a' to 'd', '2d' and '4d' but that doesn't change the sorting, it just changes the status of the little + or minus next to the product list title....it's like it thinks it is listing in desc now, and offers you to sort by asc, but it IS sorting in ASC anyway. Can anyone suggest a solution? Link to comment Share on other sites More sharing options...
sidewinder Posted July 10, 2005 Share Posted July 10, 2005 I am trying to sort descending by product name and I have tried to chane the above 'a' to 'd', '2d' and '4d' but that doesn't change the sorting, it just changes the status of the little + or minus next to the product list title....it's like it thinks it is listing in desc now, and offers you to sort by asc, but it IS sorting in ASC anyway. Can anyone suggest a solution? <{POST_SNAPBACK}> I changed this code in catalog/index.php (line 191 on mine) 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"; break; to this 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 final_price desc"; break; if you want lowest price first, then dont use 'desc' it worked for me :D :thumbsup: If you want product name desc then just adding 'desc' should work for you on the line $listing_sql .= " order by pd.products_name"; change it to $listing_sql .= " order by pd.products_name desc"; not tested tho' I wanted it by price.. and it worked... Link to comment Share on other sites More sharing options...
Guest Posted August 11, 2005 Share Posted August 11, 2005 Thanx worked for sorting by price! Link to comment Share on other sites More sharing options...
dcmo Posted August 11, 2005 Share Posted August 11, 2005 Hi, I tried this to sort by model descending, using $listing_sql .= " order by p.products_model desc"; which works fine, except the product name column heading still has the little + next to it. How can I set this properly? thanks :blink: I changed this code in catalog/index.php (line 191 on mine) 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"; break; to this 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 final_price desc"; break; if you want lowest price first, then dont use 'desc' it worked for me :D :thumbsup: If you want product name desc then just adding 'desc' should work for you on the line $listing_sql .= " order by pd.products_name"; change it to $listing_sql .= " order by pd.products_name desc"; not tested tho' I wanted it by price.. and it worked... <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.