Ensure store-scoped values are selected before default#2966
Ensure store-scoped values are selected before default#2966fballiano merged 3 commits intoOpenMage:mainfrom
Conversation
cb385b3 to
234e6e4
Compare
|
Rebased to bring the phpstan fix from last week. If someone has got the time, please check if this is a regression in OM. Cause I tested briefly in a store running OM 19.4.14 and I couldn't reproduce it. I will check again later. |
|
Just confirmed that this bug is not happening in OM 19.4.14, there must have been a change in the following versions that introduced it. |
|
@elidrissidev - Did you look in the history of the file starting with 1.9.14 to identify when the problem occurred? I looked quickly and didn't find anything. |
|
@addison74 Indeed I did. With the help of |
|
Hey @mattdavenport, are you interested in updating this PR with a proper fix now that we found the origin of this issue? |
|
@elidrissidev I unfortunately won't have time for this in the near-term. If you would like to propose a fix or keep this PR open until I'm able to return to it that's fine as well. Thanks for looking into this btw! |
|
@elidrissidev what do you think we should do with this PR? Also, I can't rebase it to main :-( |
|
Could be closed and converted into an issue until there's a proper fix for it, already was on my list for some time just can't figure it out. |
|
I think the "order by" is maybe not the cleanest solution ever but I don't see it as an ugly workaround, it's effective and quite easy and I'd probably have that instead of the bug :-) @mattdavenport would you be able to rebase this PR to the "main" branch? sadly I can't do it for you. |
|
@fballiano Agreed on the implementation. Better than nothing I suppose :). I should have some time to rebase this tomorrow so I will take a look. Thanks! |
5f4e86e to
aac60fd
Compare
|
@fballiano Should be good now. Sorry I didn't notice this was easily doable via Github UI 😄. |
|
@mattdavenport I still see it on 1.9.4.x, I see your force push but I still can't change the branch in the PR because it generated 5000+ modified files :-( |
When a category is created under a store scope before the default scope, fetching the attributes on a page load will load NULL values rendering those fields blank.
aac60fd to
6f9cc29
Compare
|
actually I tested and I can't reproduce the bug
so I don't see the bug here |
|
@fballiano To reproduce you have to create a new attribute when there are existing categories, creating the attribute does not create the EAV rows at the default scope. Then save an existing category at the store scope, now there exists EAV rows for the store but not default. Then if you save at default scope the default rows are added to EAV but the PK ids cause default values to be sorted after store values. |
|
A small optimization: When the query is for a single store it should not be necessary to sort. MySQL may already be smart enough that this doesn't matter but it wouldn't hurt. if (count($storeIds) > 1) {
$select->order('attr_table.store_id ASC');
} |
We've encountered a bug in which a user created a category under a store scope with some values filled in (description, title, etc.). They then switched to the default scope, modifying other separate fields, and then switched back to the store scope to find the data they had inputted is gone. This occurred because the
_getLoadAttributesSelect()query fetched the default values first upon going back to the store-scoped category page.To reproduce:
This PR ensures store_id is sorted
ASCto ensure the store-scoped values are also fetched properly.