Jump to content

Archived

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

mitchind

Sorting Attributes

Recommended Posts

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

$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

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

Share this post


Link to post
Share on other sites

Brilliant Just what i was looking for thanks :D

 

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

 

anyway cheers :thumbsup:

Share this post


Link to post
Share on other sites

Thank you so much for posting this SORT code, it works GREAT! :thumbsup:

 

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

 

(a) account_history_info.php

AND

(B) the order confirmation email message

 

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

 

Thanks!

 

OSCnewbie.

Share this post


Link to post
Share on other sites

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

 

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.

Share this post


Link to post
Share on other sites

Hi,

 

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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 :(

Share this post


Link to post
Share on other sites

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

 

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

$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

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


Riaan

Share this post


Link to post
Share on other sites

is there any way to code this so it sorts products alphabetically, even if they are already entered?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!!! :D

Share this post


Link to post
Share on other sites

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! :)

Share this post


Link to post
Share on other sites
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! :lol:


Rick

 

osC 2.2 MS2 051113 / STS v4.5.2

PHP 5.2.1 / MySQL 4.1.21

Linux dedicated server / RapidSSL

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

THANK YOU!!!

 

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

Share this post


Link to post
Share on other sites

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


"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Share this post


Link to post
Share on other sites

×