<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Autogedal\StockSourceRouter\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">StockSourceRouter</argument>
            <argument name="handlers" xsi:type="array">
                <item name="system" xsi:type="object">Autogedal\StockSourceRouter\Logger\Handler</item>
            </argument>
        </arguments>
    </type>

    <!-- Intercepts all custom cron stock updates (PTC, SmartBill, Carsupreme, Alfaromtrans, etc.) -->
    <!-- sortOrder 5 ensures this runs before StockLog's capture plugin (which only logs) -->
    <type name="Magento\InventoryCatalog\Model\ResourceModel\SetDataToLegacyStockItem">
        <plugin name="autogedal_stock_source_router" type="Autogedal\StockSourceRouter\Plugin\StockRouterPlugin" sortOrder="5"/>
    </type>

    <!-- Intercepts Firebear import path specifically (avoids affecting other callers of the Magento base class) -->
    <type name="Firebear\ImportExport\Model\Import\StockItemImporter">
        <plugin name="autogedal_stock_source_router_firebear" type="Autogedal\StockSourceRouter\Plugin\FirebearRouterPlugin" sortOrder="5"/>
    </type>

</config>
