<?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\CatalogInventory\Observer\ParentItemProcessorInterface">
        <plugin name="adapt_parent_stock_processor" type="Magento\InventoryConfigurableProduct\Plugin\CatalogInventory\Observer\ParentItemProcessor\AdaptParentItemProcessorPlugin"/>
    </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"/>
    </type>
    <type name="Magento\Inventory\Model\SourceItem\Command\DecrementSourceItemQty">
        <plugin name="update_parent_configurable_product_stock_status_in_legacy_stock"
                type="Magento\InventoryConfigurableProduct\Plugin\InventoryApi\UpdateParentStockStatusInLegacyStockPlugin"/>
    </type>
    <type name="Magento\InventoryApi\Api\SourceItemsSaveInterface">
        <plugin name="update_configurable_product_parent_stock_status"
                type="Magento\InventoryConfigurableProduct\Plugin\InventoryApi\UpdateConfigurableProductParentStockStatus"/>
    </type>
    <type name="Magento\CatalogInventory\Model\ResourceModel\Stock\Item">
        <plugin name="update_source_stock_for_configurable_product"
                type="Magento\InventoryConfigurableProduct\Plugin\CatalogInventory\UpdateSourceItemAtLegacyStockItemSavePlugin" />
    </type>
</config>
