Repair Magento Composite Stock Status From the CLI

A parent created before its children is stored in a state Magento never moves it out of. This marks new ones correctly and revives a catalogue already stuck.

A composite parent’s stock status is a stored flag, not a value computed at read time, and the platform only moves a parent back into stock when a second column says the current status was set automatically rather than by a person. A parent created alone — structure first, children linked in a later call — is written out of stock with that marker cleared. Nothing after that revives it: not restocking, not relinking, not reindexing, because the index faithfully reproduces the stale flag. This module marks new composites as automatically maintained so an import cannot latch them, and repairs the ones already stuck.

Typical impact: the "import worked but nothing is buyable" catalogue. On a multi-source install the same defect compounds with a cross-stock veto and leaves composite parents unsalable in every stock — measured on stock platform code, an API-loaded multi-source catalogue has no buyable composite parents at all.

Who it is for

  • Anyone whose configurable, bundle or grouped products are out of stock after an import while every child has quantity — and where reindexing changed nothing, which is the tell.
  • Multi-source installs, where the second half of the defect applies and the usual advice does not reach it.
  • Integrations that cannot send a parent together with its links, and therefore keep re-creating the state on every structural run.

Who should skip it

  • Feeds that already create the parent together with its links or options in one call. That is the cheapest fix and it needs no module: the recompute runs inside the same save and sets the marker.
  • Catalogues where a merchant deliberately sets composite stock by hand on a multi-stock setup — removing the cross-stock veto is a real behaviour change there, documented in the repository’s own limits page.
  • Anyone who can send the parent with explicit stock data marking it in stock instead. Being born in stock buys the marker on the way down.

What it does

Three parts, and the third is the one that leads people here:

  • Prevention. A newly created composite is marked as automatically maintained, so an import can no longer produce a parent in the one state the platform never moves out of.
  • The multi-source pair. Parent maintenance is gated on fewer than two enabled sources, and the per-stock salability index derives a secondary stock’s answer partly from the default stock’s stored flag. Either half alone is useless or harmful — lifting the gate on its own reproduces a known upstream defect — so both ship together.
  • Repair, from the CLI. brocode:composite-stock:revive restores the marker and re-derives the status, which is the pair that matters: restoring the marker alone only makes the next child stock write effective, and that write may never come.
bin/magento brocode:composite-stock:revive --dry-run
bin/magento brocode:composite-stock:revive
bin/magento brocode:composite-stock:revive SKU-1 SKU-2

Find the population first — parents of any composite type that are out of stock with the marker cleared cannot recover on their own, and that query is worth running before a go-live rather than after.

Upstream

Both halves were investigated against 2.4-develop and filed: magento2#41174 with a proposed six-line fix in PR #41175, and the multi-source side in inventory#3466 with regression coverage proposed in PR #3467. The single-source half may well be fixed upstream; the multi-source half is a design trade-off rather than a bug, so do not wait for it. What happens to a core PR after you open it explains why that wait runs in months.

Installation

composer require brocode/module-composite-stock-status
bin/magento module:enable BroCode_CompositeStockStatus
bin/magento setup:upgrade
bin/magento setup:di:compile

Compatibility

Magento 2 Open Source with MSI. All three composite types — configurable, bundle and grouped — each affected through its own index query. Verified on 2.4.8-p5 and 2.4.9; the creation-shape behaviour was also checked against 2.4-develop using the platform’s own integration test framework.

FAQ

Will reindexing fix this instead?

No, and that is the single most over-used diagnosis here. The index reproduces the stored flag correctly; the flag is what is wrong.

Does a routine product save undo the repair?

On released versions, a later save can clear the marker again, so a structural feed re-latches parents that are out of stock when it runs. That is exactly what the prevention half stops.

What does it deliberately not do?

It does not touch a merchant’s manual out-of-stock decision on a single-stock catalogue, and it does not reconcile quantities. It repairs the status machinery only.

Related reading

Ask a module question or suggest improvements

Tell us your use case and the module context. Spam protection is handled by ALTCHA.




More Projects