<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\OptionsIndexerInterface" type="Magento\InventoryConfigurableProduct\Pricing\Price\Indexer\OptionsIndexer" />
    <type name="Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor">
        <arguments>
            <argument name="baseSelectProcessors" xsi:type="array">
                <item name="stock_status" xsi:type="object">Magento\InventoryConfigurableProduct\Model\ResourceModel\Product\StockStatusBaseSelectProcessor</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\InventorySalesApi\Model\GetSkuFromOrderItemInterface">
        <plugin name="get_configurable_option_sku_from_order"
                type="Magento\InventoryConfigurableProduct\Plugin\Sales\GetSkuFromOrderItem"/>
    </type>
    <type name="Magento\ConfigurableProduct\Model\ResourceModel\Product\LinkedProductSelectBuilder">
        <arguments>
            <argument name="baseSelectProcessor" xsi:type="object">Magento\InventoryConfigurableProduct\Pricing\Price\LowestPriceOptionsProvider\StockStatusBaseSelectProcessor</argument>
        </arguments>
    </type>
    <type name="Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\OptionsSelectBuilder">
        <arguments>
            <argument name="selectProcessor" xsi:type="object">Magento\InventoryConfigurableProduct\Pricing\Price\Indexer\BaseStockStatusSelectProcessor</argument>
        </arguments>
    </type>
    <type name="Magento\CatalogInventory\Api\StockRegistryInterface">
        <plugin name="inventory_catalog_add_qty_to_legacy_stock_configurable"
                type="Magento\InventoryConfigurableProduct\Plugin\CatalogInventory\Api\StockRegistry\SetQtyToLegacyStock" sortOrder="100"/>
    </type>
    <type name="Magento\CatalogInventory\Model\ResourceModel\Stock\Item">
        <plugin name="after_update_stock_item_for_configurable_product"
                type="Magento\InventoryConfigurableProduct\Plugin\CatalogInventory\UpdateLegacyStockStatusForConfigurableProduct"
                sortOrder="100"/>
        <plugin name="updateStockChangedAuto" disabled="true"/>
    </type>
    <type name="Magento\InventoryCatalogApi\Model\CompositeProductStockStatusProcessorPool">
        <arguments>
            <argument name="compositeProductStockStatusProcessors" xsi:type="array">
                <item name="configurable" xsi:type="object">Magento\InventoryConfigurableProduct\Model\StockStatusProcessor</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\InventorySalesApi\Model\GetIsQtySalableInterface">
        <plugin name="inventory_configurable_product_is_any_child_salable"
                type="Magento\InventoryConfigurableProduct\Plugin\InventorySales\Model\IsProductSalableCondition\GetIsQtySalableForConfigurableProduct"/>
    </type>
    <type name="Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\GetStatusExpression">
        <arguments>
            <argument name="statusExpressions" xsi:type="array">
                <item name="configurable" xsi:type="object">Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\StatusExpression\DefaultExpression</item>
            </argument>
        </arguments>
    </type>
</config>
