Fix variations menu order not applying correctly when manually set cl… #30423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…oses #29630
All Submissions:
Changes proposed in this Pull Request:
Closes #29630
So this was a bit tricky to tackle. We basically have two ways of setting the variations menu order. One is by using drag and drop which works fine. The other way is to manually set a menu order value by clicking on the drag and drop icon as noted by the tooltip if you hover over it. This is where the issue lies. Current logic when
save_variationsaction is triggered is to refresh the menu order values so they enumerate in sequential order (1..2...3...etc). After that is done, then it tries to update the current variation that you made change to, to the new menu order value in the DB. Doing could potentially create duplicated menu order values. Now when retrieving these variations menu order, it is no guarantee the order is correct anymore because you have a duplicate value where the value for that row could come before or after the variation row you are editing. Though this fix works, I feel there might be a better way. Open to suggestions.How to test the changes in this Pull Request:
Used as variationsand then save attributes.Create variations from all attributes.NOTE:
It is normal for menu order values to be out of sequence in an incremental fashion. That is ok and will not deter from the function it is designed to do. For example if you only had 8 variations and you purposely set the 8th variation to menu order value of 10. As long as they're in an incremental menu order value sequentially without duplicates and from top down, it will work correctly.
Other information:
Changelog entry
FOR PR REVIEWER ONLY: