Make sure all linked products (related, upsells, crosssells) show up … #17885
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.
…in the backend grids and in the correct order. Fixes #13720
Description
This is a re-take of #15251
This fixes #13720 & #14050
The problem was introduced in 168701c & 308b70b
The fact that product link positions can be the same probably happens by importing products, you probably can't get to this state by just managing related, upsell or crosssell products in the adminhtml.
Next to the fix, I've also added two extra cases in the unit tests for when either the position isn't defined or doesn't exist, these are edge cases which will probably never happen, but I feel like this makes the code more robust. When the position isn't defined or doesn't exist, I've opted to set the position to
0
and this will cause those products to show up as the first ones in the list.There is a small change in the result of the
$sorterItems
variable, in that the array keys no longer follow the position exactly. But in my testing this doesn't seem to have any negative effect.Fixed Issues (if relevant)
Manual testing scenarios
catalog_product_link_attribute_int
value
column, forproduct_link_attribute_id
== 1) should be unique if you created those related products through the backendUPDATE catalog_product_link_attribute_int SET value = 1 WHERE product_link_attribute_id = 1;
Related Products, Up-Sells, and Cross-Sells
section.Contribution checklist