spooks Posted July 22, 2009 Author Share Posted July 22, 2009 you would need to look at the query getting the cart contents & put smthing like order by pd.products_name at the end 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...
Ironhalo Posted July 23, 2009 Share Posted July 23, 2009 would that be something i do in catalog/shopping cart.php or in admin/orders? still a bit confused sorry. i had a look through shopping cart.php but could not see where to put the code. is it in here somewhere in shopping cart? $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { or is it in here in admin/orders ? for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { echo ' <tr class="dataTableRow">' . "\n" . ' <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" . ' <td class="dataTableContent" valign="top">' . $order->products[$i]['name']; if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) { for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) { echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value']; if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; echo '</i></small></nobr>'; } } and if so how do i word the code? i tried: $listing_sql .= order by pd.products_name but that did not work :) Cheers, AL Link to comment Share on other sites More sharing options...
spooks Posted July 31, 2009 Author Share Posted July 31, 2009 this is for client side, so nothing to do with admin. as it states you edit index.php however u have shopping cart.php that does not exist in standard osc, so u have a template!!! Unfortunatly templates contain non-standard often out-dated code that is often somewhat modified from the core version, so are impossible to support except by the template writer, I suggest you speak to them. osC contribs & tips are written for the core version and are often not compatible with templates. 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...
vlieger Posted August 31, 2009 Share Posted August 31, 2009 Hi Sam thank you for your efforts to change the sort orders i was able to change the sort order from product name to date added but i still have an question not every category product list is suitable for the date added , some are better by name i have seen several sites here there is an drop down list above the the product list so any visitor looking through the product list can choose for themselve if they want the list sorted by date added , name a-z, or price , or even by bestsellers i haven't found an module for this and i am not an programmer it would be the ultimate if it could work this way , so visitors can chose their preferd way of sorting you as the master of product sorting do you know how this can be done ? ;) thanks ahead i look forward of your ideas Arthur Link to comment Share on other sites More sharing options...
♥ecartz Posted August 31, 2009 Share Posted August 31, 2009 Arthur, that's how it works by default. For example, at http://demo.oscommerce.com/index.php?cPath=3_10 -- click on the price heading and it will change to: http://demo.oscommerce.com/index.php?cPath...e=1&sort=3a Click again and it becomes http://demo.oscommerce.com/index.php?cPath...e=1&sort=3d All this does is change things so that a particular column is the default choice. The ability to choose is already there. It would be possible to change this to a drop down, but clicking the column header seems easier to me, particularly as it does not require any javascript to make it refresh automatically. Always back up before making changes. Link to comment Share on other sites More sharing options...
spooks Posted August 31, 2009 Author Share Posted August 31, 2009 Product Listing Enhancements, Thumbnails & Manufacturer Headings http://addons.oscommerce.com/info/6051 has drop down sort options, mainly as some of the layout options do not suite headers. 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...
vlieger Posted August 31, 2009 Share Posted August 31, 2009 Thanks for the answers @ spooks i checked that addition ,its an great addition but i don't see it has the option dopdown box for visitors to sort by date_added and bestsellers additonally to name and price and i think it would be great for your module if visitors can choose the way they want to view @ecartz i know visitor can change there view sort order tot naam z-a and price +/- by clicking on the colom header , but does the visitor knows this? i think it becomes more obvious isf there is an select sort order box , and it would by asthishing for them tosort also by besteseller and date added for some list in my shop exceeds over 1500 products and are updated almost daibut some list are pretty static and has only 20 products in it so for them it should just be a-z thanks ahead for any further idea's Arthur Link to comment Share on other sites More sharing options...
spooks Posted August 31, 2009 Author Share Posted August 31, 2009 i don't see it has the option dopdown box for visitors to sort by date_added and bestsellers date_added is not part of the sql query so it would take a few mods to include that, bestsellers would require a whole new query, so more extensive mods to add that! If you wish to comment further please do so in the support thread for Product Listing Enhancements, Thumbnails & Manufacturer Headings . :) 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...
vlieger Posted August 31, 2009 Share Posted August 31, 2009 Hi Sam i was aware that this is not an easy mod to build , therefore i am searching for people who know what they are doing several of my suppliers have this option build in their webshop one of them is murphy magic: see example http://www.murphysmagic.com/Search.aspx?a=16&c=108 (althought not oscommerce site) therefore i was wondering if this could be done, i my self think it would be a great addition especially for large productlisting with lots of changes every week so returning visitors have an easy update and see the latest additions first but than easily can change their sort view to bestesellrs or A-Z or price range i posted this comment also on the Product Listing Enhancements, Thumbnails & Manufacturer Headings Arthur Link to comment Share on other sites More sharing options...
SharonH Posted October 1, 2009 Share Posted October 1, 2009 Hi, Ok I think I read through every post under this topic and have come up with a half working solution for the code in my index.php, I realise that some index.php files may be different based on your template if you have one installed. I have version 2.2 RC2 and am using a template also. The only problem i am having now is a reverse order issue ... Here however is the only way I could get items to list by date and i know I have specified descending order but the products still display in ascending order. I have no idea how to fix that bit!!!!! I anyone can help on that front it would be super ... anything I have changed or added is in red ... 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_DATE') { $HTTP_GET_VARS['sort'] = $i+1 . 'd'; $listing_sql .= " order by p.products_date_added desc"; break; } } } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : ''); break; case 'PRODUCT_LIST_MANUFACTURER': $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $listing_sql .= " order by pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': $listing_sql .= " order by final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_DATE': $listing_sql .= " order by p.products_date_added " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; } } thanks Sharon Link to comment Share on other sites More sharing options...
spooks Posted October 1, 2009 Author Share Posted October 1, 2009 Did u read my post dated Aug 3 2008 in this thread?? U have added a constant 'PRODUCT_LIST_DATE' but have u added that to admin in the relavent place? Have u then set that as appropriate? You need also to modify the $define_list to allow for the above too. 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...
SharonH Posted October 1, 2009 Share Posted October 1, 2009 So you sorted this whole issue with that Aug 3rd post by replacing 7 lines of code with 4!!!!! Can I please delete my previous post as now I feel like an idiot! Thank goodness for people like you! Link to comment Share on other sites More sharing options...
Terrakota Posted November 6, 2009 Share Posted November 6, 2009 OOPS, did you spot the deliberate mistake? It should be: Replace with: if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { $HTTP_GET_VARS['sort'] = 0 . 'd'; $listing_sql .= " order by p.products_date_added DESC, pd.products_name"; } else { Sam, I've been trying to have my list sorted by date added and found your great and easy fix for that. Thanks! It does exactly what I want, but I noticed that now I don't have the sorting in the column heading (I had it for price and name - when you click on the heading and it sorts) as I used to have before. If I change the code back to what I have, the sorting is back. Is it supposed to not work with the heading sortings? This is the code that I've replaced with the one given by you above: if ( (!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 ($column_list[$i] == 'PRODUCT_LIST_NAME') { // $_GET['sort'] = $i+1 . 'a'; // $listing_sql .= " order by pd.products_name"; //Product sort order $_GET['sort'] = 'products_sort_order'; $listing_sql .= " order by p.products_sort_order, pd.products_name asc"; break; } } } else { Thank you very much! Link to comment Share on other sites More sharing options...
spooks Posted November 6, 2009 Author Share Posted November 6, 2009 There is no heading for date added, so it wont appear, this, as it says, just set the default order, thereafter you can click the heading to alter that. 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...
Terrakota Posted November 6, 2009 Share Posted November 6, 2009 Yes, I understand that it's just for the default, but after I change the code, the headings (name and price) are no longer clickable. And you are saying that they still should be? Link to comment Share on other sites More sharing options...
spooks Posted November 6, 2009 Author Share Posted November 6, 2009 Yes, I understand that it's just for the default, but after I change the code, the headings (name and price) are no longer clickable. And you are saying that they still should be? yes, this only sets the default, evrything else should be as b4, if its not, check your edits. 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...
Terrakota Posted November 6, 2009 Share Posted November 6, 2009 yes, this only sets the default, evrything else should be as b4, if its not, check your edits. Thanks, Sam, I've changed $HTTP_GET_VARS to $_GET, and it works now. Thank you again! Link to comment Share on other sites More sharing options...
spooks Posted November 6, 2009 Author Share Posted November 6, 2009 Thanks, Sam, I've changed $HTTP_GET_VARS to $_GET, and it works now. Thank you again! That would down to your server ($HTTP_GET_VARS is depreciated) It may be a good idea to add: $HTTP_GET_VARS =& $_GET; $HTTP_POST_VARS =& $_POST; to your application top, as osC uses $HTTP_GET_VARS a lot. 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...
Terrakota Posted November 11, 2009 Share Posted November 11, 2009 That would down to your server ($HTTP_GET_VARS is depreciated) It may be a good idea to add: $HTTP_GET_VARS =& $_GET; $HTTP_POST_VARS =& $_POST; to your application top, as osC uses $HTTP_GET_VARS a lot. Thank you, Sam, it seemed to work fine, but I added it just in case. Works great. Thank you again for showing how to change the sort order! Link to comment Share on other sites More sharing options...
Guest Posted November 17, 2009 Share Posted November 17, 2009 Hi there... the info on this thread has helped me with 2 of my stores. They sort by date wonderfully. Although, on my latest store, it's only working partially. I have sub categories and when you go to that area, where you would see all listings, it won't sort by date. My other 2 stores don't have sub categories, and they work fine. How can I make all pages listing my products to sort by date? Thank you so much for a great tweek! Link to comment Share on other sites More sharing options...
spooks Posted November 17, 2009 Author Share Posted November 17, 2009 Hi there... the info on this thread has helped me with 2 of my stores. They sort by date wonderfully. Although, on my latest store, it's only working partially. I have sub categories and when you go to that area, where you would see all listings, it won't sort by date. My other 2 stores don't have sub categories, and they work fine. How can I make all pages listing my products to sort by date? Thank you so much for a great tweek! I would mean your saying you have added some contrib for sub categories listing, so if that has added a new page then you need to apply the changes to that. With no idea of how you have altered the code I have now way of telling how it should be altered otherwise. 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 November 18, 2009 Share Posted November 18, 2009 I would mean your saying you have added some contrib for sub categories listing, so if that has added a new page then you need to apply the changes to that. With no idea of how you have altered the code I have now way of telling how it should be altered otherwise. I haven't added any contrib to have sub categories. It has to be how Osc allows it by default because I haven't added anything. When I set up my products, I made a category, and in that category more of them. So it's say clothing/shirts or clothing/pants. Any items in the secondary categories aren't listing by date. It's the same idea as just having one category folder, except I broke each area down further, again...as made available with the cart. Link to comment Share on other sites More sharing options...
Terrakota Posted November 18, 2009 Share Posted November 18, 2009 Sam, Could you help me with one more thing, please. My search results were showing alphabetically, and I want them to be the latest added products first. So, I've changed advance_search_results.php the same way as you suggested for the index.php. So, now search results are shown by date added, but oldest first, though I clearly have "desc" in the code. Why could it be? I've tryed changing it in many different ways, but it's the same. Here is the code from my advance_search_result.php. if ( (!isset($_GET['sort'])) || (!ereg('^[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) { $_GET['sort'] = 0 . 'd'; $listing_sql .= " order by p.products_date_added DESC, pd.products_name"; } else { $sort_col = substr($_GET['sort'], 0 , 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': // BOF manufacturers descriptions // $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; $order_str .= "mi.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; // EOF manufacturers descriptions 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"; break; } } $listing_sql = $select_str . $from_str . $where_str . $order_str; require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING_COL); Thank you! Link to comment Share on other sites More sharing options...
artandsports Posted November 18, 2009 Share Posted November 18, 2009 Obviously you must select the item to be sorted in admin to be displayed, otherwise your asking to sort by nothing!!! So its hardly surprising when it doesnt work!!! :rolleyes: Hello , I have tried almost all possibity and only works with original one ,I have tried like 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_QUANTITY') { $HTTP_GET_VARS['sort'] = $i+1 . 'd'; $listing_sql .= " p.products_quantity desc"; break; but that doesn't change ! I would like to do it with products_date_added, but I don't know if it's possible. Thank you for your help Link to comment Share on other sites More sharing options...
spooks Posted November 18, 2009 Author Share Posted November 18, 2009 Setting default order for advanced_search_result.php To set the default search result order to date added find(303) 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; } } } else { replace with: 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'; $order_str = " order by p.products_date_added desc, pd.products_name"; } else { note variable names differ to other file. If setting by existing headings, just use the change detailed in my OP. 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...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.