Skip to content

Conversation

@roykho
Copy link
Contributor

@roykho roykho commented Aug 4, 2021

…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_variations action 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:

  1. Create a variable product.
  2. Add a custom attribute with 20 terms.
  3. Make sure to choose Used as variations and then save attributes.
  4. Go to the variations tab and run Create variations from all attributes.
  5. You should have at least 2 pages of variations.
  6. On page 1, click on the drag and drop handle icon for the last variation.
  7. You should see a window prompt asking you for the menu order value.
  8. Enter 2 for example and ok/enter.
  9. After an AJAX refresh, you should see the last variation is now in the second position from the top.
  10. Click on each of the drag and drop handle icon to make sure the menu order values are indeed correct.
  11. Perform the same test from step 6 - 10 except this time do it from page 2 and see if the results are correct.
  12. Now test the drag and drop and make sure we don't have any regressions due to this fix.

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:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Fix - Variations menu order not applying correctly when manually set in some cases.

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@roykho roykho requested review from a team and claudiosanches and removed request for a team August 4, 2021 17:01
@roykho roykho mentioned this pull request Aug 4, 2021
3 tasks
@jonathansadowski jonathansadowski requested review from jonathansadowski and removed request for claudiosanches August 9, 2021 15:04
Copy link
Contributor

@jonathansadowski jonathansadowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested after the update to single query, and everything still works as expected. Good work 👍

Note, the nightly test failure is unrelated, see p1628528704105900-slack-C0E1AV8T0

@jonathansadowski jonathansadowski merged commit 7ef09ba into trunk Aug 9, 2021
@jonathansadowski jonathansadowski deleted the fix/29630 branch August 9, 2021 19:32
@github-actions github-actions bot added this to the 5.7.0 milestone Aug 9, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2021

Hi @jonathansadowski, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the status: needs changelog label
  • Add the status: needs testing instructions label

@jonathansadowski jonathansadowski added release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Aug 9, 2021
@roykho roykho added the release: highlight Issues that have a high user impact and need to be discussed/paid attention to. label Aug 20, 2021
@rodelgc rodelgc added testing instructions added and removed release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: highlight Issues that have a high user impact and need to be discussed/paid attention to.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variation Order Does Not Save

4 participants