Page 1 of 1

[1.5.1.3] Sort order of Option Values in Admin

Posted: Thu Oct 13, 2011 9:34 pm
by teratyke
Hi
I have quite a lot of option values under one of my options, maybe 50 or so.
In the admin these seem to display in no particular order (possibly the order they were entered in). I would like to sort these in the admin by using the sort order value for each option value. The front end does sort like this. I've been through the sql code in the model admin/model/catalog/option.php but it looks like it looks like its working in the way I want - I could be looking at the wrong code of course.

Code: Select all

	public function getOptionValues($option_id) {
		$option_value_data = array();
		
		$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value ov LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE ov.option_id = '" . (int)$option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order ASC");
Help appreciated.
Rob

screenshot attached - I should add that further downthe list are option values with a sort order of 42,43 etc
Capture.JPG

Capture.JPG (64 KiB) Viewed 6169 times


Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Thu Dec 15, 2011 1:05 am
by partizzzzzan
admin/model/catalog/option.php
Find

Code: Select all

$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
replace

Code: Select all

$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'" . "ORDER BY sort_order ASC");

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Thu Dec 15, 2011 4:53 am
by teratyke
Thank you so much for your help. I'll try that change tomorrow.

Many thanks.
Rob

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Fri Dec 16, 2011 8:20 pm
by teratyke
Great thanks for your help. Works a treat.

If anyone else wants this here is a vqmod..


Rob

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Tue May 01, 2012 10:05 pm
by oneglory
You can also have it sort within the drop down when you're actually trying to add the option to a product.

in 1.5.2.x

in product.php find:

Code: Select all

$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_option WHERE option_id = '" . (int)$option_id . "'");
replace it with:

Code: Select all

$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_option WHERE option_id = '" . (int)$option_id . "'" . "ORDER BY sort_order ASC");

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Sat May 19, 2012 4:00 am
by theking1010
Hi oneglory,

I have OC version 1.5.2.1 and I replaced the code in the product.php in the admin folder as you instructed, however I don't see an option to sort the form. Please view screenshot.

Thanks!

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Thu Aug 02, 2012 11:50 pm
by otd
did anyone get this working on teh option tab on teh product pahe for 1.5.1.3??

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Fri Sep 21, 2012 5:06 pm
by eselpee
Did anyone got this working for 1.5.1.3 yet?

Re: [1.5.1.3] Sort order of Option Values in Admin

Posted: Fri Sep 21, 2012 9:13 pm
by eselpee
partizzzzzan wrote:admin/model/catalog/option.php
Find

Code: Select all

$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
replace

Code: Select all

$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'" . "ORDER BY sort_order ASC");
If I am correct this sort the option on id number?
I am looking for the code that sorts it on the description.

Is that possible?