peteravu Posted November 28, 2011 Share Posted November 28, 2011 I know this thread is about product listing. But I need to sort the shopping cart after product name and then sort after attribute name? I can’t find out how to do . I use 2.3.1. Thanks to all that contributed to separate_price_per_customers_4.2.2_for_2.3.1, Add Multiple Products with plus/minus buttons, One Page Checkout for 2.3.1, Multi Attribute V2, Login Box Club osCommerce Shipping Date Chooser for 2.3.1, Quickly Update Product Stock 3.8.5 Español and order number in email subject Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds. my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1 Link to comment Share on other sites More sharing options...
cyberworlukltd Posted November 29, 2011 Share Posted November 29, 2011 Spooks, you are the Best I did install the Ultimate SEO URLs contrib a while back. When I turn that off, my sort order problem goes away!!! Thanks so much for your help in pointing that out to me. I have not found the fix yet, but I see there are several versions after the one I installed, so it may be in one the new ones or in the thread somewhere. I guess will have to go find it. Thanks again Link to comment Share on other sites More sharing options...
oxwivi Posted March 12, 2012 Share Posted March 12, 2012 I used Easy Populate to restore products back to osCommerce, but I want the latest models to show first. But there was a couple issues that made it difficult to achieve using the latest-first modification mentioned in the first page: Since all of the products were restored from backup, all of the product's date added are exactly the same. So they sorted by the names. The names, or rather, there are no names. We just copy the model number in the name field, and they go A-01, A-02, etc. With the higher numbers obviously being the latest. So I did 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)) ) { $HTTP_GET_VARS['sort'] = 0 . 'd'; $listing_sql .= " order by p.products_date_added DESC, p.products_model"; } else { But it doesn't take care of the latest model issue. How do I sort by date and models? Link to comment Share on other sites More sharing options...
spooks Posted March 12, 2012 Author Share Posted March 12, 2012 all of the product's date added are exactly the same It sounds like you have no data in your database related to the ordering you want, so its impossible to re-order that way. I would look at modifying Easy Populate so it uses the original content for 'date added' instead of altering it, have you looked at the Easy Populate thread on this? 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...
oxwivi Posted March 12, 2012 Share Posted March 12, 2012 It sounds like you have no data in your database related to the ordering you want, so its impossible to re-order that way. I would look at modifying Easy Populate so it uses the original content for 'date added' instead of altering it, have you looked at the Easy Populate thread on this? Well, it maybe my fault that I did not keep the original data, but that does not solve the issue. I use EP to add multiple products at once, and that's another scenario with the same issue. As a solution, I want to sort first with date, then with models. How can I do that? Link to comment Share on other sites More sharing options...
spooks Posted March 12, 2012 Author Share Posted March 12, 2012 Sorry, I `m not clear, does not your order by p.products_date_added DESC, p.products_model sort by model, your issue being all the dates are the same. PS If you has auto backup installed (see signature) you could have gone back easily. 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...
oxwivi Posted March 12, 2012 Share Posted March 12, 2012 Well, I don't understand it myself. Is it sorting by models ascending or descending? Currently, the list goes A-01, A-02, and so on. If I add A-04 to A-10, I want it to go A-10, A-09, A-08 and so on till A-01. Link to comment Share on other sites More sharing options...
spooks Posted March 12, 2012 Author Share Posted March 12, 2012 So are your saying you want is sorted ascending for alphabetical values, but descending for any subsequent numerical? 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...
oxwivi Posted March 12, 2012 Share Posted March 12, 2012 I want to sort the whole value descending. There is no need to specifically sort the alphabets differently. Link to comment Share on other sites More sharing options...
spooks Posted March 12, 2012 Author Share Posted March 12, 2012 Could you check you're using the query you think you are by adding at the bottom of product_listing.php just before the final ?> echo '<hr>' . $listing_sql . '<hr>'; and saying what is shows. 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...
oxwivi Posted March 13, 2012 Share Posted March 13, 2012 Sorry for the late response (was already night the last I replied). So I did this to product_listing.php: <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span> </div> echo '<hr>' . $listing_sql . '<hr>'; <?php } ?> </div> I included a few lines of code before and after the line you told me to add to give you an idea. Anyway, I don't think it worked as expected since this was the result: echo '' . $listing_sql . ' '; Link to comment Share on other sites More sharing options...
spooks Posted March 13, 2012 Author Share Posted March 13, 2012 @@oxwivi That line is php, so must go inside the php tags, not outside, which is why I said just before the last ?> which is a php closing tag 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...
oxwivi Posted March 13, 2012 Share Posted March 13, 2012 Oops, got confused by the question mark of the <?php there. So this time: <?php } echo '<hr>' . $listing_sql . '<hr>'; ?> And the result: select p.products_image, p.products_model, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, products_to_categories p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '4' order by p.products_date_added DESC, p.products_model Link to comment Share on other sites More sharing options...
spooks Posted March 13, 2012 Author Share Posted March 13, 2012 Sorry, did'nt spot for looking before, i think the query your wanting is: order by p.products_date_added DESC, p.products_model DESC 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...
oxwivi Posted March 14, 2012 Share Posted March 14, 2012 Excellente! It's working as I wanted! Does the DESC thingmajigger imply sort by descending? Thanks for all the help! Link to comment Share on other sites More sharing options...
spooks Posted March 14, 2012 Author Share Posted March 14, 2012 Exactly :) 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...
dolphspeed99 Posted April 2, 2012 Share Posted April 2, 2012 Hello, I read all this topic and other just like it and I still didn't find the answer to my problem, I hope someone can help me. On osCommerce 2.2 I need to display the products in the following order: first, in alphabetical order, all the products that have stock quantity more than zero, and then, in alphabetical order, all the product with stock zero. Can anyone help me with the code that I need to insert in the php files? Thanks! PS: I need to mention that I have a private work done on my site and a sort of a watermark automatically appears when a product's stock reaches zero. When I change that quantity to a value higher then zero the watermark automatically disappears. I just need all the products with zero stock to be listed last in the respective type of view (category view, manufacturer view, new products view, specials view, x-sales view) Link to comment Share on other sites More sharing options...
spooks Posted April 3, 2012 Author Share Posted April 3, 2012 You would need to modify index.php to present your first query result to the product_listing.php module (as it does currently) then create a second and represent, it may need a number of alterations due to all the filter options on that page. 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...
dolphspeed99 Posted April 5, 2012 Share Posted April 5, 2012 I'm not sure what you just said, but I'll give it a try. :) Link to comment Share on other sites More sharing options...
dolphspeed99 Posted April 28, 2012 Share Posted April 28, 2012 I couldn't do it so I hired a programmer to do this for me Link to comment Share on other sites More sharing options...
oxwivi Posted May 1, 2012 Share Posted May 1, 2012 order by p.products_date_added DESC, p.products_model DESC I'm getting back to you about it late, very late, but there's an issue. On the first pages of any category, everything works fine, But going to the subsequent pages would show this top of the list: Deprecated: Function ereg() is deprecated in /home/hijabi6/public_html/index.php on line159 Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted May 1, 2012 Share Posted May 1, 2012 I'm getting back to you about it late, very late, but there's an issue. On the first pages of any category, everything works fine, But going to the subsequent pages would show this top of the list: The fix for just this http://www.oscommerce.com/community/contributions,7394 or migrate to 2.3.1 and fix this and other issues along the way ... KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
oxwivi Posted May 1, 2012 Share Posted May 1, 2012 or migrate to 2.3.1 and fix this and other issues along the way ... I'm already using osC 2.3.1. I think this issue appeared after using sorting code recommended in this thread. You can check the last two pages for the code I was told to use, if interested. Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted May 1, 2012 Share Posted May 1, 2012 I'm not an ereg / preg expert, I just know it was fixed in 2.3.1, if you find line 159 in index.php on your site, i would expect it to become clearer. in the source of 2.3.1. you have lots of replacements, so i'd expect you'd find some example of how to change things. here is some thread from the forum that might be helpful http://www.oscommerce.com/forums/topic/341737-function-ereg-replace-is-deprecated/ KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
oxwivi Posted May 2, 2012 Share Posted May 2, 2012 Well, the changed sort order indeed used ereg: 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 DESC"; However, changing it to !preg and going to next pages (as I described the issue first) does not load the list or the boxes and shows this error: Fatal error: Call to undefined function preg() in /home/hijabi6/public_html/index.php on line159 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.