Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sign in to follow this  
homerS

Sort the Product-Options?!

Recommended Posts

hi!

 

does anyone know how to sort the options in the product_info?

 

for example, i want to have

 

Size [Radio Button]

Text [Text Box]

Color [Drop Down]

 

but the options are listed alphabetically:

 

Color

Size

Text

 

any ideas?

 

thanks!

Share this post


Link to post
Share on other sites
hi!

 

does anyone know how to sort the options in the product_info?

 

for example, i want to have

 

Size [Radio Button]

Text [Text Box]

Color [Drop Down]

 

but the options are listed alphabetically:

 

Color

Size

Text

 

any ideas?

 

thanks!

 

Yeah, I've researched this before.

 

I have BTS installed and the code is found in my template/contents directory, filename product_info.tpl.php. I believe standard installation without BTS would be in catalog/product_info.php. Find this code around line 150:

 

//clr 030714 update query to pull option_type
     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment 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");

 

The very last line, change order by popt.products_options_name to order by popt.products_options_id and it will sort by the ID of the product option. Just make sure that you enter your product options in admin in the order you want them to appear in the catalog.

 

You can sort the attributes in the drop down, select list options, too. It's found further down in the file and looks like this:

 

//clr 030714 default is select list

//clr 030714 reset selected_attribute variable

$selected_attribute = false;

$products_options_array = array();

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" . "order by pov.products_options_values_name");

 

Insert the code in blue to sort alphabetically, or, replace "name" with "id" to sort in order of entery into admin. I've found with so many options in my drop-down lists, that if I want the list in a certain non-alphebetical order, I just add "A. Option #1", "B. Option #2" and so on. Works for me...

 

Hope this helps.


Brian Neuman

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×