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

I final get solution for this:
from admin/model/catalog/option.php
look for the following near bottom:
change to
then it is okay.
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 . "'");
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.
Who is online
Users browsing this forum: No registered users and 7 guests