Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sorting Product Attributes


damastav

Recommended Posts

Is there a way to set the default attribute selected for certain products? I can add Product attributes but for some reason, osCommerce selects the more expensive option as the default. Is there a way to make the default to the option that does not add to the price?

Link to comment
Share on other sites

There is an Attributes Sorter & Copier contribution that allows you to select the order. Also, you could play around with adding order by to the SQL query. Something like order by pa.options_values_price would probably work.

 

Hth,

Matt

Link to comment
Share on other sites

Matt is right, the easiest way is to change the query in product_info.php

 

On some systems you have to use the group by popt.products_options_name or it will list each attribute for the number of options that attribute has. My Windows system did not require the group by statement but my Linux system did require it.

 

Example: If you had color as an attribute with Blue and Red as values for that attribute, without group by some systems would render this.

 

Color: Blue (Drop down with Blue and Red as options)

Color: Blue (Drop down with Blue and Red as options)

 

Adding group by will work on both Windows and Linux systems.

 

 

Change this:

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");

 

 

 

To this:

// Changed order by to options_values_price

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' group by popt.products_options_name order by patrib.options_values_price");

while (!succeed) {try()};

 

GMT -6:00

Link to comment
Share on other sites

Thanks. It worked for most of the products. There are only a few exceptions, but I don't understand why, since the SQL query in product_info.php should be run the same for all products. Any ideas why I am getting these exceptions?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...