Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 2 votes

Sorting Attributes


59 replies to this topic

#1 mitchind

  • Community Member
  • 3 posts
  • Real Name:Don Mitchinson

Posted 29 November 2004, 20:49

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.

#2 deadmatt

  • Community Member
  • 10 posts
  • Real Name:Matt

Posted 05 July 2005, 19:06

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:

#3 plasmz

  • Community Member
  • 6 posts
  • Real Name:pam boyd

Posted 07 August 2005, 08:52

Thank you for posting this... I've been going around in circles for days... :D pmb

#4 OSCnewbie

  • Community Member
  • 39 posts
  • Real Name:Pamela
  • Location:Sunny Arizona

Posted 17 November 2005, 17:35

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.

#5 erik_1099

  • Community Member
  • 10 posts
  • Real Name:Erik Nielsen

Posted 22 November 2005, 20:43

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

View Postmitchind, on Nov 29 2004, 08:49 PM, said:

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.


#6 OSCnewbie

  • Community Member
  • 39 posts
  • Real Name:Pamela
  • Location:Sunny Arizona

Posted 22 November 2005, 21:59

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.

#7 bobsi18

  • Community Member
  • 436 posts
  • Real Name:bobsi18
  • Gender:Female
  • Location:Melbourne, Australia

Posted 17 April 2006, 12:08

FANTASTIC!!! THANKS!!!

~Barbara~
Easy Populate*Purchase Without Account*2nd Manufacturer*Product Listing in Columns*Actual Attribute Price*Add Weight to Product Attribute*New Attributes Manager*Display Cart In Header*Ship In Cart*AusPost*AusBank*Credit Class & Gift Voucher*Specials on default*Extra Fields*Header Tags*Image Magic*Points Reward*Printer Friendly Product*Simple Search Box*Specials valid from*Select specials*STS plus*Xsell*Active Countries*Credit Card by Fax/Phone*Center Shop* Online/Offline*Product in cart alert*Ultimate SEO urls*Dynamic Site map (modified)*Google Site Feed*Froogle Site feed*Updated spiders.txt*Auto mysql backup*Admin Access 22A*Fancier Invoice & Packingslip v6.1

#8 mperez3100

  • Community Member
  • 1 posts
  • Real Name:Miguel Perez

Posted 30 July 2006, 15:16

View Postbobsi18, on Apr 17 2006, 07:08 AM, said:

FANTASTIC!!! THANKS!!!

~Barbara~


SUPER!!!

#9 Wigzilla

  • Community Member
  • 11 posts
  • Real Name:Katy

Posted 21 September 2006, 22:14

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

#10 survequip

  • Community Member
  • 67 posts
  • Real Name:Paul

Posted 26 September 2006, 13:09

View PostWigzilla, on Sep 21 2006, 11:14 PM, said:

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

#11 Barefoot Kid

  • Community Member
  • 54 posts
  • Real Name:Hung Diep
  • Location:London, UK

Posted 23 November 2006, 12:48

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

#12 rassa

  • Community Member
  • 53 posts
  • Real Name:diana
  • Gender:Female
  • Location:sweden

Posted 05 March 2007, 09:12

thank you so much for the code

#13 rkscscc

  • Community Member
  • 97 posts
  • Real Name:RKS Computer Solutions
  • Gender:Male
  • Location:South Africa

Posted 09 March 2007, 23:37

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

View Postmitchind, on Nov 29 2004, 10:49 PM, said:

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

#14 noelove

  • Community Member
  • 30 posts
  • Real Name:Noel Trujillo

Posted 01 April 2007, 00:51

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

#15 dp1726

  • Community Member
  • 30 posts
  • Real Name:DP Glass

Posted 02 April 2007, 19:37

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

#16 R1Andy

  • Community Member
  • 8 posts
  • Real Name:Andy Adams

Posted 13 April 2007, 13:11

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

#17 benspun

  • Community Member
  • 96 posts
  • Real Name:Benoit Martin
  • Gender:Male
  • Location:Québec, Canada (but presently roaming in Europe and Asia)

Posted 20 April 2007, 15:06

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

#18 kewlceo

  • Community Member
  • 7 posts
  • Real Name:Rick Taylor
  • Location:SoCal

Posted 05 May 2007, 12:57

View Postbenspun, on Apr 20 2007, 08:06 AM, said:

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

#19 xecutech

  • Community Member
  • 85 posts
  • Real Name:Tom Featherstone
  • Gender:Male
  • Location:Nashville

Posted 02 June 2007, 13:30

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!

#20 Jayman007

  • Community Member
  • 43 posts
  • Real Name:Jay Man

Posted 04 June 2007, 09:12

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.