Taven Posted June 19, 2009 Share Posted June 19, 2009 Hi all, I feel like I'm missing something obvious. Is there anywhere I can organize my products by date added or something else than the default alphabetical? That's for when customers are browsing through products (such as inside categories). By default it's alphabetical and I can't figure out where to change this. If there's some code digging I have to do, that's no problem- I just need to know where to start. Thanks for the help! OSC rocks! :) -Taven Link to comment Share on other sites More sharing options...
spooks Posted June 19, 2009 Share Posted June 19, 2009 I delt with that in this thread http://www.oscommerce.com/forums/index.php?sho...c=308798&hl= 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...
Taven Posted June 19, 2009 Author Share Posted June 19, 2009 I delt with that in this thread http://www.oscommerce.com/forums/index.php?sho...c=308798&hl= Excellent, thank you so much for your topic! I've done what you've shown and changed the code 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)) ) { $_GET['sort'] = 0 . 'd'; $sort_sql = " order by p.products_date_added ASC, pd.products_name"; } else { However, for whatever reason, my products are listing in DESC order (first added at the top to newest added at the bottom). No matter what I change I can't get it to ASC (newest products at the top, first added at the bottom). :huh: Am I missing something really simple? Or is there another bit of code I need to change here? Link to comment Share on other sites More sharing options...
Taven Posted June 19, 2009 Author Share Posted June 19, 2009 Actually, I feel like I should have changed: $_GET['sort'] = 0 . 'd'; to $_GET['sort'] = 0 . 'a'; along with what I had changed previously: $sort_sql = " order by p.products_date_added ASC, pd.products_name"; But that didn't work either. :huh: Removing the a and the ASC also didn't work. Hmm. I'm not sure what else to change. Any help would be greatly appreciated, as always :) Will look at this all again tomorrow- perhaps I'm tired. -Taven Link to comment Share on other sites More sharing options...
Taven Posted June 20, 2009 Author Share Posted June 20, 2009 Urg! I just can't get this to work. I noticed that on my "New Products" module, that the products were being listed by date_added and in the correct order, newest(top) to oldest(bottom). So I checked the code for it in new_products.php and found: order by p.products_date_added desc Ok. So "desc" seems to list them from newest(top) to oldest(bottom). Makes sense. So then why does... if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { $_GET['sort'] = 0 . 'd'; $sort_sql = " order by p.products_date_added desc, pd.products"; } else { ... list my products from oldest(top) to newest(bottom), the complete opposite of the new products page? And when I change desc to asc and d to a absolutely nothing changes with the order of the products? I must be missing something. I just don't know what. :( Link to comment Share on other sites More sharing options...
Taven Posted July 6, 2009 Author Share Posted July 6, 2009 It's been a while I know; but I've only gotten the chance to give it a good look today. :lol: For others with the problem above, here's the solution. The line: $sort_sql = " order by p.products_date_added desc, pd.products"; Should actually be: $listing_sql .= " order by p.products_date_added desc, pd.products_name"; Here's Why: First of all, $sort_sql is not used anywhere else in the code- making it useless. The correct variable to be setting is $listing_sql. Second, you don't assign the string to $listing_sql, as that overwrites the beginning half of the query already assigned to it. Instead, you want to add it to the end. So, replace '=', with '.=' Third, pd.products does not exist in the database at all- there is no "products" column in the table "products_description". The correct column is 'products_name', so in full, 'pd.products_name' Perhaps the original code was written for an older version of OSCommerce? Otherwise- I'm not quite sure why the original code worked for anyone. :huh: With those three things corrected, all products will successfully list by the date they were added. :) -Taven Link to comment Share on other sites More sharing options...
spooks Posted July 6, 2009 Share Posted July 6, 2009 This seems to be u fixing an issue that is perculier to u, if you read the post I refered to it gave $listing_sql .= but u used $sort_sql = and found it didnt work till you 'fixed' it by putting $listing_sql .= why did'nt you just read my thread through first? 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...
Taven Posted July 8, 2009 Author Share Posted July 8, 2009 This seems to be u fixing an issue that is perculier to u, if you read the post I refered to it gave $listing_sql .= but u used $sort_sql = and found it didnt work till you 'fixed' it by putting $listing_sql .= why did'nt you just read my thread through first? I did. ;) But I obviously missed something however, or in an attempt to get it to work changed something breaking it further. Instead of leaving my "simple mistake" question completely unanswered however -as it had been for two weeks or so- I decided to answer it myself once I found the time to solve it, just in case someone would find themselves in the same or similar situation, however rare that might be. Looking back, yes, your code should have worked the first time I used it. :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.