Model

StockIndex

Magento\CatalogInventory\Model\StockIndex

What it does

This class manages the stock status index for products in Magento 2, ensuring inventory availability is correctly calculated and stored.

Developers would use this to rebuild stock status data or update product stock statuses across websites, particularly when dealing with configurable products where parent-child relationships affect availability.

It handles complex scenarios like checking if all required child products are in stock before marking a parent product as available.

Public Methods

  • rebuild()
  • updateProductStockStatus()