Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HELP !@#! with sort order!!!!


elixir

Recommended Posts

I need help getting the products in a catagory NOT to be displayed alphabetically

 

what page to I edit.. what do I do.. need help. I do. yes.

 

remember I don't want to have my products desplayed aplhabetically

 

I do want them to be displayed as of last date added to the database.

Link to comment
Share on other sites

You need to alter your order by clause.

 

product_listing.php

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Well, there is SQL embedded into the PHP that queries the database and returns the products to an array. This SQL also ORDERS the products according to the field specified. You have to change the field specified from the name of the product to the date the product was entered.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

No, the SQL that you need to change is embedded in PHP. I believe it's in the product_listing.php file.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

I am having a similar problem, and I do not see a product_listing.php file either. I was able to order my products by model number by changing the catalog/default.php "order by" clause around line 379, but I must have changed too much (and didn't back it up, of course, because I KNEW what I was doing), and I lost my item display. If you can help me by giving me back the lines of code around that area, maybe we can work through this together before my husband comes home and finds out what I did to his site? Thanks!

--David's gal

Link to comment
Share on other sites

Well, that's a pretty important lesson you've learned there.

 

Perhaps you should download the whole package again, and ifnd the original code you're looking for.

 

Best of luck.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Lesson learned, but I did manage to fix it and now my products do display by item number. My apologies to elixir, though, as I don't think what I was doing will help him after all.

Link to comment
Share on other sites

It's includes/modules/product_listing.php. Note: it is called from index.php (default.php in older versions). The code that you want to change is in index.php around lines 191-8:

    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

    if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
       $listing_sql .= " order by p.products_date_added";
     }

Hth,

Matt

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...