OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Sorting Attributes
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Tips and Tricks
mitchind
I put this in place for myself because it was driving me crazy trying to get the product options displayed in the order I wanted. All the sorting contributions I came across were difficult to implement or changed a lot of code.

All I wanted was something that showed my options in order of price. Or at the very least showed them in the order I entered them.

It's a simple fix that takes less than a minute.

What it does...
First - sorts by price
Second - if price is same (or 0), it sorts based on the order that the option was entered.

File to change ... /catalog/product_info.php

Replace this line
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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");


With this line
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, pa.products_attributes_id 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 pa.options_values_price, pa.products_attributes_id");


Hope someone else will find this useful.
deadmatt
Brilliant Just what i was looking for thanks biggrin.gif

Helps to prevent my customers from automatically choosing the most expensive upgrades because they didnt see the options lol

anyway cheers thumbsup.gif
plasmz
Thank you for posting this... I've been going around in circles for days... biggrin.gif pmb
OSCnewbie
Thank you so much for posting this SORT code, it works GREAT! thumbsup.gif

Do you know how I could get it to sort by product attributes HERE too:

(a) account_history_info.php
AND
(cool.gif the order confirmation email message

(My PHP skills are "hurtin' for certain") blush.gif

Thanks!

OSCnewbie.
erik_1099
You are my hero. This has been driving me nuts.

QUOTE (mitchind @ Nov 29 2004, 08:49 PM) *
I put this in place for myself because it was driving me crazy trying to get the product options displayed in the order I wanted. All the sorting contributions I came across were difficult to implement or changed a lot of code.
OSCnewbie
Hi,

blink.gif Is anyone else having problems getting the sort order to work in "account_history_info.php" and the order-confirmation email message that goes out?

--OSCnewbie.
bobsi18
FANTASTIC!!! THANKS!!!

~Barbara~
mperez3100
QUOTE (bobsi18 @ Apr 17 2006, 07:08 AM) *
FANTASTIC!!! THANKS!!!

~Barbara~



SUPER!!!
Wigzilla
Hi,
I am having a similar problem, but, it is with colors. I want my color drop down to go 1, 1B, 2, etc. but instead of the way I put it in, it just mixes itself up. Will this coding help me for that? If so could you please give me a step by step of how to install it, i'm very new, any help would be great.
thank you
survequip
QUOTE (Wigzilla @ Sep 21 2006, 11:14 PM) *
Hi,
I am having a similar problem, but, it is with colors. I want my color drop down to go 1, 1B, 2, etc. but instead of the way I put it in, it just mixes itself up. Will this coding help me for that? If so could you please give me a step by step of how to install it, i'm very new, any help would be great.
thank you


Wicked! But I have to agree, any idea on getting colours in order that we wish or to default to one colour?

Thanks
Barefoot Kid
this sorts the attribute by price all right but for me it fails to take into account whether theres a + or - sign in front of the price so the smallest prices are listed last sad.gif
rassa
thank you so much for the code
rkscscc
Don,

If this site had a rating function on users, you'd get about 493 out of 10 right now... Been browsing contribs, fighting on the forum and basically all I ended up doing is being more bald than 2 weeks ago.....

You sir, are an absolute star!!!!!

Riaan

QUOTE (mitchind @ Nov 29 2004, 10:49 PM) *
I put this in place for myself because it was driving me crazy trying to get the product options displayed in the order I wanted. All the sorting contributions I came across were difficult to implement or changed a lot of code.

All I wanted was something that showed my options in order of price. Or at the very least showed them in the order I entered them.

It's a simple fix that takes less than a minute.

What it does...
First - sorts by price
Second - if price is same (or 0), it sorts based on the order that the option was entered.

File to change ... /catalog/product_info.php

Replace this line
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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");


With this line
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, pa.products_attributes_id 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 pa.options_values_price, pa.products_attributes_id");


Hope someone else will find this useful.
noelove
is there any way to code this so it sorts products alphabetically, even if they are already entered?
dp1726
Great idea
But does anybody know how to change the code so that it sorts by model number.
example 1 2 4 7 12 14 18 ect.
Dave
R1Andy
YOU ARE A LIFESAVER!!! Thanks so much, I was really starting to question my choice of shopping carts until I stumbled on this post which put 126 of my entries in order.

THANK YOU!!! biggrin.gif
benspun
Yes, indeed, a great post, very useful for me as well!

It's interesting how a single message can continue to collect thanks from people more than 2 years after having been written! smile.gif
kewlceo
QUOTE (benspun @ Apr 20 2007, 08:06 AM) *
Yes, indeed, a great post, very useful for me as well!

Same here. I have a line of watch bands in the catalog I'm building, and as an option, you can add a Rolex watch. Before applying this mod, the watch would be included by default, and I was worried about people getting sticker shock on accident. Now it's all sorted properly. Whew!

The original poster averages one post per year, it seems. I'm off to go see if his other two messages are as helpful as this one! laugh.gif
xecutech
Just like everyone else here..... you are the man!!!!!

I have been fighting with this for days and you saved me from hours of searching this forum. I actually found this with a google search, as I had given up on the search feature on the forum.

Thank you very much!
Jayman007
How can I setup the order or Product Options (not attributes)? This has been driving me crazy as I have found and implemented contribs for sorting products and product attributes but NOTHING for sorting the product options. I will need to be able to ender a value for the option sorting and not just use price or order entered.
lazykins
QUOTE (noelove @ Mar 31 2007, 07:51 PM) *
is there any way to code this so it sorts products alphabetically, even if they are already entered?


Yes, I am still looking for a way sort option values by name.
This should be simple. Can a better-coder-than-me tell me if I can modify product_info.php to do this?

I need to control what appears first in the list of product options.

I tried installing McGrath's Sorter/Copier but I think maaaaaybe it isn't fully functional with the latest version of the cart. While I didn't receive any errors, and the copy function worked fine, the sorting feature did nothing. I uninstalled it.

Back to square 1.

Amy
diatomdan
THANK YOU!!!

QUOTE (rkscscc @ Mar 9 2007, 05:37 PM) *
Don,

If this site had a rating function on users, you'd get about 493 out of 10 right now... Been browsing contribs, fighting on the forum and basically all I ended up doing is being more bald than 2 weeks ago.....

You sir, are an absolute star!!!!!

Riaan
rabbitseffort
this attribute sorter is the only one I use on every project I set up, in my opinion it is the best
HERE

It adds the ability to sort the option on the product entry page in admin, sooo easy to use

I use v1.11, if you also want the product tabs contribution I have made it easy with a small addon I added to that package a while back

Here is another great one that adds many options

HTH
myluckypaws
hello,
anyone has any idea on how to sort it based on size?
small, medium, large...even if entered in order, this thing goes crazy sad.gif
Zyrul
thank you!!! save my day thumbsup.gif
simolingerie
thumbsup.gif
QUOTE (mitchind @ Nov 29 2004, 08:49 PM) *
I put this in place for myself because it was driving me crazy trying to get the product options displayed in the order I wanted. All the sorting contributions I came across were difficult to implement or changed a lot of code.

All I wanted was something that showed my options in order of price. Or at the very least showed them in the order I entered them.

It's a simple fix that takes less than a minute.

What it does...
First - sorts by price
Second - if price is same (or 0), it sorts based on the order that the option was entered.

File to change ... /catalog/product_info.php

Replace this line
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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");


With this line
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, pa.products_attributes_id 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 pa.options_values_price, pa.products_attributes_id");


Hope someone else will find this useful.


Thank you!!
nath69uk
Thanks so much.
rharkey
thumbsup.gif Awesome. It took all of 20 seconds. The ordering was something that was also driving me crazy. Thanks!!

QUOTE (mitchind @ Nov 29 2004, 08:49 PM) *
I put this in place for myself because it was driving me crazy trying to get the product options displayed in the order I wanted. All the sorting contributions I came across were difficult to implement or changed a lot of code.

All I wanted was something that showed my options in order of price. Or at the very least showed them in the order I entered them.

It's a simple fix that takes less than a minute.

What it does...
First - sorts by price
Second - if price is same (or 0), it sorts based on the order that the option was entered.

File to change ... /catalog/product_info.php

Replace this line
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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");


With this line
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, pa.products_attributes_id 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 pa.options_values_price, pa.products_attributes_id");


Hope someone else will find this useful.
Flo Bee
QUOTE (rharkey @ Mar 20 2008, 06:07 AM) *
thumbsup.gif Awesome. It took all of 20 seconds. The ordering was something that was also driving me crazy. Thanks!!


Great mod! Very simple to set up and that's the best part!

Attributes suck bad enough, but this really helps.
scribionics
Thanks, this suggestion (Product Attributes Sort Order v1.0) made product_info.php work very much better (looking like order now rather than chaos, always a plus), and clarified some things about variable names:

pa. is a Product Attribute, such as "flavor".
pov. is a Product Option Value. such as "chocolate".

I think being able to see that now will help me solve some other problems.
ryecandy
This fix rocks...
For anybody wondering, I saw another version of this fix that will actually sort your attributes out in alphabetical order. I'm sorry that I cannot find that code right now but is is very similar to the 'sort by admin order' (which I currently use in conjunction with my AJAX Attribute Manager, for the control panel)

Anyhow, thanks for the fix mitchind thumbsup.gif
denacarol
thumbsup.gif Way more than helpful dude! Saved me a TON of time. Thank goodness for Google and your sorting contribution!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.