Page 1 of 1

Sort Order for Option Value Name on Admin Side

Posted: Sun Jan 22, 2012 9:58 am
by cmikel
Is there a simple way to change the sort order from entry sort order to alpha sort order for the "Option Value Name" under options on the admin side.

For example when you go to Catalog > Options > Option Name (ie Color) > Edit > Option Value Name

The colors are listed in the way they were entered - Red, Purple, Blue, Green, White, etc....instead I would like the default sort order to be Alphabetical so Blue, Green, Purple, Red White, etc....

I know you could use sort order but when you have over 100+ Option Value Names, it would be helpful for these to be in Alpha order...

thanks!!

Re: Sort Order for Option Value Name on Admin Side

Posted: Fri Sep 21, 2012 2:58 pm
by eselpee
Did you find a solution for this?

Re: Sort Order for Option Value Name on Admin Side

Posted: Tue Nov 06, 2012 1:13 am
by Sokonomi
I first posted here with a help request but then decided to dive in myself.

What i did was open /admin/model/catalog/option.php
And find this code:

Code: Select all

$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");
Replaced it with this

Code: Select all

$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 ovd.name ASC");
Notice at the very end, one says ORDER BY ov.sort_order originally, and I changed it to ORDER BY ovd.name.

What this does, is it now sorts the entries in the dropdown where you actually select the option values. I haven't managed to make the same happen for where you enter the option values, but ill keep looking.

Re: Sort Order for Option Value Name on Admin Side

Posted: Mon Jan 21, 2013 6:28 pm
by dan74mm
Sokonomi wrote:I first posted here with a help request but then decided to dive in myself.

What i did was open /admin/model/catalog/option.php
And find this code:

Code: Select all

$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");
Replaced it with this

Code: Select all

$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 ovd.name ASC");
Notice at the very end, one says ORDER BY ov.sort_order originally, and I changed it to ORDER BY ovd.name.

What this does, is it now sorts the entries in the dropdown where you actually select the option values. I haven't managed to make the same happen for where you enter the option values, but ill keep looking.
@ Sokonomi: - Thank you very much! Tested on OC_v1.5.1.2 and it's working ok !!! Thank you again!!! :ok:

Re: Sort Order for Option Value Name on Admin Side

Posted: Thu May 23, 2013 12:02 pm
by sunrisephp
I final get solution for this:

from admin/model/catalog/option.php

look for the following near bottom:

Code: Select all

	public function getOptionValueDescriptions($option_id) {
		$option_value_data = array();
		
//		$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
change to

Code: Select all

	public function getOptionValueDescriptions($option_id) {
		$option_value_data = array();
		
//		$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
                $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 ovd.name ASC");


then it is okay.