Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Default Sort Order By Price Not Product Name?


DazedAndConfused

Recommended Posts

I'm simply trying to get the products (on all listings) to sort by price (highest to lowest) instead of product name by default. I've searched all the forums and even downloaded a few contributions I thought would work.

 

It seems like I'm just looking for the location to change the variable to default all product listings to ORDER by PRODUCT_LIST_PRICE DESC.

 

Thanks in advance.... I'd like to actually rest tonight instead of throwing my laptop through a wall!!!!!

Link to comment
Share on other sites

In catalog/index.php change:

 

        if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by pd.products_name";
         break;

 

to:

 

        if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by final price desc";
         break;

 

This will sort descendingly - use 'asc' to sort ascendingly.

 

Matti

Link to comment
Share on other sites

  • 4 weeks later...

The folder osCommerce is probably the catalog folder in your case. The catalog folder will have checkout_shipping.php, create_account.php, product_info.php, etc. in it. includes and images will be subdirectories of the catalog folder.

 

Hth,

Matt

Link to comment
Share on other sites

Hello

 

Tried it and got

 

1064 - You have an error in your SQL syntax near 'price asc limit 0, 20' at line 1

 

select p.products_image, pd.products_name, 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, products_to_categories p2c left join specials s on p.products_id = s.products_id 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 = '76' order by final price asc limit 0, 20

 

 

We've adjusted currencies.php in classes to show VAT & non VAT prices. Is there an alternative SQL field name we can use to get the same effect?

Citizen of US Minor Outlying Islands

Link to comment
Share on other sites

This is the correct code to insert

 

if ($column_list[$i] == 'PRODUCT_LIST_PRICE') {
        $HTTP_GET_VARS['sort'] = $i+1 . 'a';
        $listing_sql .= " order by final_price asc";
        break;

 

The two things changed are:

 

'PRODUCT_LIST_PRICE'

 

final_price

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...