-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
v2.4.7-p9
Steps to reproduce
When using the addProductsToCart mutation with parent_sku and a child sku (as documented here) to add a configurable product to the cart, the item is added as a SimpleCartItem instead of a ConfigurableCartItem. This results in incorrect product URLs, missing thumbnails, and missing configurable option data in the cart response.
- Create a configurable product (e.g.
ParentItem) with a simple child variant (e.g.ParentItem-Variant). - Add the product to the cart using
addProductsToCartwithparent_sku:
mutation {
addProductsToCart(
cartId: "{{cartId}}"
cartItems: [
{
parent_sku: "ParentItem"
sku: "ParentItem-Variant"
quantity: 1
}
]
) {
cart {
items {
__typename
product {
name
sku
url_key
thumbnail { url }
}
... on ConfigurableCartItem {
configurable_options {
option_label
value_label
}
}
}
}
}
}- Observe the cart response.
Expected result
The cart item should be a ConfigurableCartItem with:
productreferencing the parent configurable product (correcturl_key,thumbnail, etc.)configurable_optionspopulated with the selected variant optionsconfigured_variantavailable for querying the selected simple product's data
Actual result
The cart item is a SimpleCartItem with:
productreferencing the child simple product directlyurl_keyis the child's URL key (which typically has no frontend route)thumbnailis a placeholder image (the child simple product often has no image assigned)- No
configurable_optionsdata
Additional information
There are two SuperAttributeDataProvider classes that handle resolving super_attribute data for configurable products:
| Class | Used by | Handles parent_sku? |
|---|---|---|
Magento\ConfigurableProductGraphQl\Model\Cart\BuyRequest\SuperAttributeDataProvider |
addConfigurableProductsToCart |
Yes |
Magento\QuoteConfigurableOptions\Model\Cart\BuyRequest\SuperAttributeDataProvider |
addProductsToCart |
No |
The newer provider (QuoteConfigurableOptions) only resolves super_attribute data from selected_options (base64-encoded UIDs). It does not read parent_sku or getParentSku() from the CartItem DTO at all, despite the CartItem class fully supporting it.
Additionally, Magento\Quote\Model\Cart\AddProductsToCart::addItemToCart loads the product by $cartItem->getSku() (line 160), which is the child SKU. Even if super_attribute were correctly resolved, Quote::addProduct() receives the child simple product, whose type instance (Simple) ignores super_attribute data entirely. The configurable type instance on the parent product is what processes super_attribute.
The QuoteConfigurableOptions SuperAttributeDataProvider should fall back to resolving super_attribute from parent_sku + child sku when selected_options does not contain configurable option data. The existing logic in ConfigurableProductGraphQl\SuperAttributeDataProvider already does this correctly.
Additionally, AddProductsToCart::addItemToCart should load the parent product (via parent_sku) instead of the child when parent_sku is present, so that the configurable type instance processes the buy request.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status