Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sorting Options...suddenly random


Guest

Recommended Posts

I am building 6 shopping carts at the moment. For the first 3 whenever I added product attribute options like size, model, color etc. they would always display in whatever order I added them. Ex: If I accidentally did the sizing like: XS,SM,L,XXL,XL that's how it would sort them. So, I got in the habit of adding sizes, colors, etc. in the order I wanted them to display in a browser. Same for colors and anything else. Biggest issue was size...like shoe sizes 5 thru 15 look much better and easier to view when they are numerical order. That's all worked fine for me on the first 3 carts. Now, for whatever reason on the 4th cart I'm doing it seems to display all the attributes in total random order. I can't seem to find any reason whey this one would be different. Looking at shoe sizes like: 8, 13, 5, 7, 10, 7 is very annoying. I see there are a couple of contributions I can download and install the code...but I don't really want to do that if I don't have to. I checked the version of all the carts I'm setting up and they are all the same version and release (version 2.2ms2, rel.1).

Link to comment
Share on other sites

The random options is because there is no sort in the default query so you are at the mercy of MYSQL. No guarentee of any sort sequence.

 

To sort by the "options_value_id" field add the sort field to the query in catalog/product_info.php

 

Change This

$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 = '" . $products_options_name['products_options_id'] .

"' and pa.options_values_id = pov.products_options_values_id and

pov.language_id = '" . $languages_id . "'");

 

to this:

 

$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 = '" . $products_options_name['products_options_id'] .

"' and pa.options_values_id = pov.products_options_values_id and

pov.language_id = '" . $languages_id . "' order by

pa.options_values_id");

 

HTH

Tom

Link to comment
Share on other sites

That makes sense, thank you. It just seems weird that I loaded 6 carts one after another to the server, all same version/release and the first 3 I setup seemed to sort with the ID# as you suggested I use as a default...but on the 4th one it is totally random. I have however downloaded and installed the Forrest Miller contribution to sort attributes. For newbies like me it was a bit of a challenge to do the first step, but I have posted what I have learned on page 5 here of the contributions support thread on this.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...