Post by billynoah » Sat Aug 31, 2013 5:02 am

Ever notice that when you are editing option values in the admin panel they don't seem to appear in any particular order? Personally, I'd like the admin panel to respect the sort order I've set for option values.

This just replaces the admin database query with the slightly more complex catalog database query which sorts your option values properly when you edit a product in the admin panel.

Cheers.

Code: Select all

	<file name="admin/model/catalog/product.php">
		<operation>
			<search position="replace"><![CDATA[$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "'");]]></search>
				<add><![CDATA[
			$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order");
			]]></add>
		</operation>
	</file>

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by billynoah » Tue Oct 08, 2013 8:08 am

The above post orders options while editing a product. Here's another bit to order them while editing the options themselves.

Code: Select all

	<file name="admin/model/catalog/option.php">
		<operation>
			<search position="replace"><![CDATA[$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");]]></search>
			<add><![CDATA[$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "' ORDER BY sort_order ASC");]]></add>
		</operation>
	</file>

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by js132 » Fri Oct 18, 2013 6:08 am

Thanks for the mods ... they work great!

Newbie

Posts

Joined
Mon Feb 11, 2013 1:10 am

Post by billynoah » Tue Oct 22, 2013 3:59 am

you're most welcome, glad this works for you. I've got 60+ option values for a few of mine and sorting them this way helped me a lot.

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by Ben1989 » Wed Jan 08, 2014 9:27 pm

Where do I put this code?

Newbie

Posts

Joined
Wed Dec 18, 2013 7:53 pm

Post by webvet » Wed Jan 08, 2014 10:08 pm

Ben1989

Firstly, you need to have installed vQmod

Secondly, you need to create an xml file using the guidance here: http://code.google.com/p/vqmod/wiki/Scripting

Drop this into your vqmod/xml folder and hey presto!

Hope that helps...

Genuine, Honest Opencart Support @ http://webvetservices.com


User avatar
Active Member

Posts

Joined
Thu May 14, 2009 2:04 am
Location - Shropshire, UK

Post by -Monique- » Mon Mar 02, 2015 7:30 pm

Thanks for the code to change the order of option values in the admin panel. It works great! I was wondering if it is also possible to sort the option values by name from A-Z when editing a product in the admin panel.

Hopefully someone can help me with this.

Newbie

Posts

Joined
Fri Apr 04, 2014 8:35 pm
Who is online

Users browsing this forum: No registered users and 9 guests