magento / magento/inventory

Configurable product in cart is "IN_STOCK" even if the associated simple product is out of stock

Open
#3,406 1 comment 0 reactions 0 assignees View on GitHub
Progress: ready for grooming
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

### Summary (*)
Adding configurable product with simple product that has stock and arriving to the checkout when the product has no stock available. Quiring the GRAPHQL endpoint if the product has stock result in "IN_STOCK" instead of "OUT_OF_STOCK" (only the configurable product is taken into account)

### Examples (*)
When running the getCheckoutDetails graphql query on a cart with configurable product and simple product that had available qty when added to cart the query returns the product as in stock
```
query getCheckoutDetails($cartId: String!) {
cart(cart_id: $cartId) {
id
...CheckoutPageFragment
...ItemsReviewFragment
__typename
}
}
fragment CheckoutPageFragment on Cart {
id
items {
uid
product {
uid
stock_status
__typename
}
__typename
}
total_quantity
available_payment_methods {
code
__typename
}
__typename
}
fragment ItemsReviewFragment on Cart {
id
total_quantity
items {
uid
product {
uid
sku
name
thumbnail {
url
__typename
}
__typename
}
prices {
price {
currency
value
__typename
}
row_total {
value
__typename
}
total_item_discount {
value
__typename
}
__typename
}
quantity
... on ConfigurableCartItem {
configurable_options {
configurable_product_option_uid
option_label
configurable_product_option_value_uid
value_label
__typename
}
__typename
}
__typename
}
__typename
}
```
variables:
```
{
"cartId": "XXXXX"
}
```
This query is mapped to the PHP file Magento\InventoryGraphQl\Model\Resolver\StockStatusProvider where in the resolve function the product model is the configurable product only
note: the PHP file listed above looks like a copy of the PHP file Magento\CatalogInventoryGraphQl\Model\Resolver\StockStatusProvider

### Proposed solution
A solution to this could be passing the cart object with the selected values of the configuration and testing each added simple product by itself

Contributor guide

Open the contributing guide

Research direction

Start with Magento\InventoryGraphQl\Model\Resolver\StockStatusProvider and compare it with Magento\CatalogInventoryGraphQl\Model\Resolver\StockStatusProvider. Reproduce the getCheckoutDetails query using a configurable cart whose selected simple product becomes unavailable, then trace how the resolver receives the cart item and selected configuration. Done means the GraphQL stock_status reflects the selected simple product in this checkout case, with regression coverage for the reported scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.