Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

sorting an attribute by option name


Guest

Recommended Posts

does anybody know of an contrib or mod to sort attributes by option name?

 

Product Attributes Sort Order v1.0 seems to only sort by value, any other contribs or options available.

 

:-"

Link to comment
Share on other sites

You can change the query directly in the catalog.product_info.php file and add the sort to the end of the query.

 

Find this code:

 

$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 . "'");

 

and change it 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 pov.products_options_values_name");

 

HTH

Tom

Link to comment
Share on other sites

I made the changes as you suggested, but I am still unable to sort by product option name, it still sorts aphabetically, which doesn't work for me. are we missing something?

Link to comment
Share on other sites

matrixxx63,

 

I don't think anyone's written that. The contributions have focused on sorting the values in the drop downs, not the order of the display of available options.

 

It shouldn't be hard to hack together.

 

ed

Link to comment
Share on other sites

Ed, being new to oscommerce my knowlege of the code is neal. I haven't much of a clue as to what would be needed and how to get started. If you have any suggestions, I would greatly appreciate it.

 

Howard

Link to comment
Share on other sites

Howard,

 

I just want to be clear on my understanding. Using the order by in the SQL, your attributes show as:

 

Bamboo Backing add $75.00:

Bow wood:

Draw length:

Hickory Backing add $75.00:

Inlay antler:

Inlay exotic wood:

Inlay horn:

Length of bow:

 

etc. You want to change the order that they are listed. Not the order of the values in the drop down. Right?

 

ed

Link to comment
Share on other sites

Howard,

 

I don't know of any contributions that do that. Master Products or QTPro might but I don't know them well enough to say. I'm planning on updating Unique Attributes in the next 2 weeks and could add this in. Let me know.

 

ed

Link to comment
Share on other sites

Howard,

 

I noticed from one of earlier posts that you have installed "Options Type Feature" contribution.

 

I don't have that code, however in the standard product_info.php there are two queries that you would change. The first query sorts the attribute options by alphabetical name. Then within each attribute there is a query that retrieves the actual drop down values. The default product_info.php has no sort on the second query. My post above sorts the drop downs into alphabetical order.

 

If you want the first query to sort the Attributes by "id" that would allow you to add the attribute and display it in the sequence you added it to the database.

 

However since you are using a contribution, you'd need to make the query/sort changes within the contribution, or go back to the original product_info.php and make the appropriate sort changes.

 

Tom

Link to comment
Share on other sites

Tom, thanks for your help. I removed all the sort contrib's and only have the option type contrib installed. I need to research the code and figure out how to add the sort to the attribute option value and option name, these would be two distinct sorts. Mevid may have a solution developed soon.

 

thanks

Link to comment
Share on other sites

  • 1 year later...
You can change the query directly in the catalog.product_info.php file and add the sort to the end of the query.

 

Find this code:

 

$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 . "'");

 

and change it 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 pov.products_options_values_name");

 

HTH

Tom

 

 

Thanks, Tom. This did the trick. (I adapted it to sort by id.) And thanks for your many contributions to the community. This newbie sure appreciates your generosity!

Troy

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...