Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sort the Product-Options?!


homerS

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!

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...