Was tryng to work on something related to attributes being displayed in the proper sequence and came across something I thought may be mysql server dependent, but on further testing does not appear to be so simple of a .
Discovery was in includes/modules/attributes.php and may be an issue in other files if in the same format.
When the sort order for option names is identified in product info as by sort order followed by name, then in the file, the sort order becomes: order by LPAD(popt.products_options_sort_order,11,"0")
But, when this is run perhaps the first time, then the data is presented as desired in sort order followed by option name order, but if that page is reloaded or the query performed again then the sort order is lost to return to being in the order of the options_id.. I thought that I had posted about this once before a long while back, and maybe the "solution" still stands that nothing need be done, but I thought I would bring it to light again.
This is fine if a sort order is applied to the option name, but when the sort order is 0 for all option names (or the same) the result is by option name id not by option name.
I then went to phpmyadmin and entered the exact query as created for the Execute, and got the same result, but the query was also slightly modified to add a space after each piece of information in the LPAD statement. When I then refed that query in, the result came back correctly sequenced (the first time)...
When I then went back to the attributes.php file and added the same space after each comma, then the attributes were presented in the correct sequence once correctly and then subsequent tries while on the same page were again presented incorrectly...
So yes it seems odd that it sorts properly one time but then subsequently incorrectly, but also the statement in admin is to sort by sort order and option name or to sort by option name. The sort provided to the query though only enforces either sort order or option name not both.
So my recommendation after all this is to change the LPAD statement here (and in other places entered the same) to be like:
Code:
if (PRODUCTS_OPTIONS_SORT_ORDER == '0') {
$options_order_by= ' order by LPAD(popt.products_options_sort_order, 11, "0"), popt.products_options_name';
} else {
$options_order_by= ' order by popt.products_options_name';
}
Server OS: Linux 3.2.61-grsec-modsign
Database: MySQL 5.6.25-log
HTTP Server: Apache
PHP Version: 5.6.10 (Zend: 2.6.0)
PHP Memory Limit: 128M
PHP File Uploads: On
Max Size: 20M
PHP Safe Mode: Off
POST Max Size: 20M
Let me know if there is any specific or other data needed to reproduce this issue...
Even after accessing tools->Store Manager->Update All Products' Attribute Sort Orders
to match Option Value Default Sort Orders, the data still appears not in the sequence described by the admin option for sorting option names... Evidence also seen in the attributes controller.. Looks like either the admin description is incorrect, or the code at some point along the way is missing something to provide the response described... I found several other locations where the sort order of option_names was generated the same as provided in includes/modules/attributes.php Would be nice to have the full functionality described by adding the sort of products_options_name instead of removing the text of the option selection. :/
Bookmarks