Fix hub product variants mapping unmatched permutations to first SKU - #2593
Open
wychoong wants to merge 1 commit into
Open
Fix hub product variants mapping unmatched permutations to first SKU#2593wychoong wants to merge 1 commit into
wychoong wants to merge 1 commit into
Conversation
When collect()->search() finds no match it returns false, and PHP coerces $variants[false] to $variants[0], so sparse option matrices steal the first variant's SKU. Only map real matches, and skip unmatched rows when fillMissing is false. Co-authored-by: Cursor <cursoragent@cursor.com>
wychoong
force-pushed
the
fix/map-variants-false-index
branch
from
August 4, 2026 05:17
f0878c7 to
a057cfb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
MapVariantsToProductOptionswhere unmatched cartesian option permutations were incorrectly bound to the first product variant.collect()->search()returnsfalseon no match, and PHP coerces$variants[false]to$variants[0].fillMissing: false(used by the Product Options / Variants hub widget), unmatched permutations are now skipped instead of inventing mislabelled rows.fillMissing: trueleaving unmatched rows without an existing SKU.Reproduction
On a product with shared options and a non-cartesian variant matrix (for example Size/Colour/Length combinations that do not all exist),
/hub/products/{id}/variantscould show the first SKU under the wrong option labels.Test plan
MapVariantsToProductOptionsTest./vendor/bin/pest tests/admin/Unit/Actions/Products/MapVariantsToProductOptionsTest.php/hub/products/{id}/variantsOption column matches each variant’s pivot values for a sparse shared-option product