Post by cmikel » Sun Jan 22, 2012 9:58 am

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

Newbie

Posts

Joined
Sat Jun 25, 2011 7:52 am

Post by eselpee » Fri Sep 21, 2012 2:58 pm

Did you find a solution for this?

OC 1.5.1.3
Vqmod 2.1.5


New member

Posts

Joined
Mon Oct 03, 2011 5:37 am

Post by Sokonomi » Tue Nov 06, 2012 1:13 am

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.

Active Member

Posts

Joined
Sun Sep 30, 2012 4:52 am

Post by dan74mm » Mon Jan 21, 2013 6:28 pm

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:

New member

Posts

Joined
Sat Oct 22, 2011 11:08 am

Post by sunrisephp » Thu May 23, 2013 12:02 pm

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.

New member

Posts

Joined
Fri Sep 07, 2012 4:05 pm
Who is online

Users browsing this forum: No registered users and 5 guests