Page 1 of 1
sort order product option values
Posted: Mon Jun 21, 2010 2:06 am
by booyakan
How can I display product option values alphabetically without using the sort oder? I'd like to just call from the database but I cannot find the code.
Re: sort order product option values
Posted: Mon Jun 21, 2010 2:53 am
by Xsecrets
have you tried just setting all the sort orders to the same value like 0?
Re: sort order product option values
Posted: Mon Jun 21, 2010 2:59 am
by booyakan
yes but they are ordered by the way i input them. this is a problem because if i have 25 options and then want to add a few new ones later i would have to redo all of the sort numbers.
i think i found the code to change this in controller/model/controller/product.php
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY sort_order");
if this is the correct code, do you know what i would change it to?
Re: sort order product option values
Posted: Mon Jun 21, 2010 3:21 am
by Xsecrets
that query won't cut it because that table doesn't have the names in it. the names are in product_option_value_description table which that query doesn't reference.
Re: sort order product option values
Posted: Mon Jun 21, 2010 3:26 am
by booyakan
yea i just noticed that. if u have any other ideas i would really appreciate it. i am only trying to sort them alphabetically for one product_id.
Re: sort order product option values
Posted: Thu Jun 24, 2010 2:42 am
by Radium
I am also having this issue. Shouldn't product options be sorted alphanumerically by name by default?
Re: sort order product option values
Posted: Thu Jul 01, 2010 4:18 am
by Radium
Probably not a recommended solution, but I got the product options to sort by name (value description) in OpenCart 1.4.8b by doing this modification...
I modified the file
catalog/model/catalog/product.php
Replace:
Code: Select all
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY sort_order");
With:
Code: Select all
// $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY sort_order");
$product_option_value_query = $this->db->query("SELECT
" . DB_PREFIX . "product_option_value.product_option_value_id,
" . DB_PREFIX . "product_option_value_description.name,
" . DB_PREFIX . "product_option_value.price,
" . DB_PREFIX . "product_option_value.prefix
FROM " . DB_PREFIX . "product_option_value
LEFT JOIN " . DB_PREFIX . "product_option_value_description
ON " . DB_PREFIX . "product_option_value.product_option_value_id = " . DB_PREFIX . "product_option_value_description.product_option_value_id
WHERE " . DB_PREFIX . "product_option_value.product_option_id = " . (int)$product_option['product_option_id'] . "
ORDER BY sort_order, name");
Re: sort order product option values
Posted: Tue Jul 19, 2011 12:04 am
by amelie
I attempted the code by Radium for 1.4.9.4, but it didn't work as expected
It pulled up this error:
Code: Select all
Notice: Undefined index: extra in /home/decalb5/public_html/store/catalog/model/catalog/product.php on line 454
Line 454:
Code: Select all
'extras' => unserialize($product_option_value['extra']),
Full block where line 454 is located:
Code: Select all
$product_option_value_data[] = array(
'product_option_value_id' => $product_option_value['product_option_value_id'],
'name' => $product_option_value_description_query->row['name'],
'price' => $product_option_value['price'],
'prefix' => $product_option_value['prefix'],
'extras' => unserialize($product_option_value['extra']),
'extra' => unserialize($product_option['extra'])
);
Any suggestions?
Re: sort order product option values
Posted: Sat Jun 16, 2012 1:24 pm
by djoliverm
Sorry to bump the thread, but has anyone figured this out? I too have run into this problem, where the instructions say that leaving the sort order at 0 should automatically sort alphabetically but the drop down menu to select an option is a whole mess.
Re: sort order product option values
Posted: Tue Nov 06, 2012 1:08 am
by Sokonomi
Im gonna give this one another bump, we need a fix!
Re: sort order product option values
Posted: Mon Jan 07, 2013 9:38 am
by bigal
I am using v1.5.4.1. You can change sort in the admin control panel.
Go to control panel - Catalog -> Options -> Edit your options -> and change the sort number numbers.
Re: sort order product option values
Posted: Mon Jan 07, 2013 5:14 pm
by Sokonomi
Thats the problem, were looking for a solution.
Re: sort order product option values
Posted: Sun May 05, 2013 5:27 pm
by mmazurek
Hi,
I've got the same problem, but for now, there's an free extension for this:
http://www.opencart.com/index.php?route ... on_id=7522
Maybe this would help someone.
Re: sort order product option values
Posted: Sun May 05, 2013 5:48 pm
by Sokonomi
Thats what ive been using, it works, but only on the front end.
The back end is still in complete shambles.
Re: sort order product option values
Posted: Sun May 05, 2013 9:10 pm
by mmazurek
Yes! True. It can be a pain

But maybe someone will post a solution for this in this thread.
Edit:
I've found something here:
http://forum.opencart.com/viewtopic.php?f=20&t=43356
Re: sort order product option values
Posted: Sun May 05, 2013 11:46 pm
by justcurious
Re: sort order product option values
Posted: Mon May 06, 2013 1:55 am
by mmazurek
Oh... Thanks a lot!!!!

)))) It works for me.
Re: sort order product option values
Posted: Mon May 06, 2013 2:09 am
by Sokonomi
It works on the back end too?
