Page 1 of 1

Order Options Alphabetical

Posted: Sun Nov 17, 2019 5:56 am
by bobbart
I have been looking for a way to force my options to list Alphabetically. Can someone help me? I really dont want to spend more money so I hope there is a free method

Re: Order Options Alphabetical

Posted: Sun Nov 17, 2019 4:15 pm
by opencartmart
at which end, admin or front?

Re: Order Options Alphabetical

Posted: Mon Nov 18, 2019 11:19 pm
by paulfeakins
bobbart wrote:
Sun Nov 17, 2019 5:56 am
I have been looking for a way to force my options to list Alphabetically. Can someone help me? I really dont want to spend more money so I hope there is a free method
Find the controller for that part in the admin and add a sort order at the part where it gets the options.

Re: Order Options Alphabetical

Posted: Tue Nov 19, 2019 6:23 am
by bobbart
I am unsure how to do that. Any guidance would be great appreciated.

Re: Order Options Alphabetical

Posted: Tue Nov 19, 2019 6:25 am
by bobbart
opencartmart wrote:
Sun Nov 17, 2019 4:15 pm
at which end, admin or front?
I guess for both but at least for the customer view to help them located the scent they are looking for.

Re: Order Options Alphabetical

Posted: Tue Nov 19, 2019 12:45 pm
by letxobnav
in catalog/model/catalog/product.php

for the option values:
find

Code: Select all

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"
change to

Code: Select all

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, ovd.name"
if you leave the individual sort order fields equal it should now sort on the option name ascending.
I.e. it sorts on the manual sort order first, then name.

for the options themselves:
find:

Code: Select all

"SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"
change to:

Code: Select all

"SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order, od.name"
if you leave the individual sort order fields equal it should now sort on the option name ascending.
I.e. it sorts on the manual sort order first, then name.

Re: Order Options Alphabetical

Posted: Wed Nov 20, 2019 3:12 am
by bobbart
Thank you for the reply and suggestion. However I made the changes and refreshed as well as a ctl-F5 and its not changing the order. I have made all the option value sort orders 0.
Any other ideas or did I do something wrong?

Re: Order Options Alphabetical

Posted: Wed Nov 20, 2019 4:21 am
by letxobnav
any extensions running perhaps?

Re: Order Options Alphabetical

Posted: Wed Nov 20, 2019 5:18 am
by bobbart
Sorry for my error in doing the following
1. Modifications cache clear
This caused it to start to work however it shown another issue I have.
2. I had to fix a few issues I had with option values not being added properly via a modifications extension MASS products update

After making your file modifications and the other listed changes its now working as it should. I can not thank you enough for your help.
Sincerely, THANK YOU