Skip to content

fix(wishlist-graphql): resolve configured_variant for parent_sku+sku input (#40588)#40834

Open
lbajsarowicz wants to merge 2 commits into
magento:2.4-developfrom
lbajsarowicz:fix/40588-wishlist-configured-variant
Open

fix(wishlist-graphql): resolve configured_variant for parent_sku+sku input (#40588)#40834
lbajsarowicz wants to merge 2 commits into
magento:2.4-developfrom
lbajsarowicz:fix/40588-wishlist-configured-variant

Conversation

@lbajsarowicz
Copy link
Copy Markdown
Contributor

Description

addProductsToWishlist accepts both selected_options (encoded option IDs) and
parent_sku + sku to identify a configurable child. Only the
selected_options input ran through SuperAttributeDataProvider, so when a
caller supplied parent_sku + child sku the buy request never carried
super_attribute, the wishlist item never recorded a simple_product option,
and configured_variant resolved to null.

Added ChildSkuDataProvider: when parent_sku is set, sku differs, and no
selected_options were sent, load both products, walk the parent's
configurable attributes, and emit super_attribute mapping each
attribute_id to the child's stored value. Wired into the existing
BuyRequestBuilder provider list in etc/graphql/di.xml.

Fixes #40588

Fixed Issues

Manual testing scenarios

mutation {
  addProductsToWishlist(
    wishlistId: "1"
    wishlistItems: [{ parent_sku: "configurable-parent", sku: "configurable-red", quantity: 1 }]
  ) {
    wishlist {
      items_v2(currentPage: 1, pageSize: 5) {
        items {
          __typename
          ... on ConfigurableWishlistItem { configured_variant { sku } }
        }
      }
    }
    user_errors { code message }
  }
}

Before: configured_variant is null. After: configured_variant.sku == "configurable-red".

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (183 Wishlist unit tests)
  • Changes to the codebase comply with technical guidelines

…rable child by SKU

addProductsToWishlist accepts both `selected_options` (encoded option IDs)
and `parent_sku` + `sku` to identify a configurable child. Only the
selected_options input ran through SuperAttributeDataProvider, so when a
caller supplied parent_sku + child sku the buy request never carried
`super_attribute`, the wishlist item never recorded a `simple_product`
option, and `configured_variant` resolved to null.

Add ChildSkuDataProvider: when parent_sku is set, sku differs, and no
selected_options were sent, load both products, walk the parent's
configurable attributes, and emit `super_attribute` => attribute_id mapped
to the child's stored value. Wired into the existing BuyRequestBuilder
provider list in etc/graphql/di.xml.

Fixes magento#40588
@m2-assistant
Copy link
Copy Markdown

m2-assistant Bot commented May 25, 2026

Hi @lbajsarowicz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@lbajsarowicz
Copy link
Copy Markdown
Contributor Author

@magento run all tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label May 26, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Pull Requests Dashboard May 26, 2026
…HPCS violations

Add PHPUnit test class covering all execution paths of ChildSkuDataProvider:
happy path super_attribute map build, early returns for selected_options present,
parent_sku equals sku, no parent_sku, NoSuchEntityException, and non-configurable
parent type. Use Magento\Catalog\Model\Product mocks so getData() is mockable
without resorting to interface mocks with addMethods().
@lbajsarowicz
Copy link
Copy Markdown
Contributor Author

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

addProductsToWishlist mutation is not returning configured variant (Selected variant) while adding child product

2 participants