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

    <type name="Magento\Catalog\Block\Adminhtml\Category\AbstractCategory">
        <plugin name="FiloBlu_CategoryPlugin" type="FiloBlu\Flow\Plugin\CategoryPlugin" />
    </type>

    <virtualType name="AnagraficheLoggerProvider" type="FiloBlu\Flow\Helper\LoggerProvider">
        <arguments>
            <argument name="filename" xsi:type="string">mod2-flow-process-anagrafiche</argument>
        </arguments>
    </virtualType>

    <virtualType name="IteLoggerProvider" type="FiloBlu\Flow\Helper\LoggerProvider">
        <arguments>
            <argument name="filename" xsi:type="string">mod2-flow-process-ite</argument>
        </arguments>
    </virtualType>

    <virtualType name="FtpLoggerProvider" type="FiloBlu\Flow\Helper\LoggerProvider">
        <arguments>
            <argument name="filename" xsi:type="string">connector</argument>
        </arguments>
    </virtualType>

    <virtualType name="SFtpLoggerProvider" type="FiloBlu\Flow\Helper\LoggerProvider">
        <arguments>
            <argument name="filename" xsi:type="string">connector</argument>
        </arguments>
    </virtualType>

    <type name="FiloBlu\Flow\Model\From\Product">
        <arguments>
            <argument name="loggerProvider" xsi:type="object">IteLoggerProvider</argument>
        </arguments>
    </type>

    <type name="FiloBlu\Flow\Model\Connector\Ftp">
        <arguments>
            <argument name="_loggerProvider" xsi:type="object">FtpLoggerProvider</argument>
        </arguments>
    </type>

    <type name="FiloBlu\Flow\Model\Connector\SFtpConnector">
        <arguments>
            <argument name="_loggerProvider" xsi:type="object">SFtpLoggerProvider</argument>
        </arguments>
    </type>

    <type name="Magento\Framework\Console\CommandList">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="flow_fetch" xsi:type="object">FiloBlu\Flow\Console\Command\FetchCommand</item>
                <item name="flow_receive" xsi:type="object">FiloBlu\Flow\Console\Command\ReceiveCommand</item>
                <item name="flow_parse" xsi:type="object">FiloBlu\Flow\Console\Command\ParseCommand</item>
                <item name="flow_process" xsi:type="object">FiloBlu\Flow\Console\Command\ProcessCommand</item>
                <item name="flow_critical" xsi:type="object">FiloBlu\Flow\Console\Command\CriticalCommand</item>
                <item name="flow_cycle" xsi:type="object">FiloBlu\Flow\Console\Command\CycleCommand</item>
                <item name="flow_reset" xsi:type="object">FiloBlu\Flow\Console\Command\ResetCommand</item>
                <item name="flow_list" xsi:type="object">FiloBlu\Flow\Console\Command\ListCommand</item>
                <item name="flow_missingparents" xsi:type="object">FiloBlu\Flow\Console\Command\MissingparentsCommand</item>
                <item name="flow_copytoconfigurable" xsi:type="object">FiloBlu\Flow\Console\Command\CopyToConfigurableCommand</item>
                <item name="flow_assigngroupedtosharedcatalogs" xsi:type="object">FiloBlu\Flow\Console\Command\AssignGroupedToSharedCatalogs</item>
                <item name="flow_copytosimple" xsi:type="object">FiloBlu\Flow\Console\Command\CopyToSimpleCommand</item>
            </argument>
        </arguments>
    </type>

    <type name="FiloBlu\Flow\Helper\Website" shared="true" />
    <type name="FiloBlu\Flow\Model\Actions\From\Addtocategory">
        <arguments>
            <argument name="categoryHelper" xsi:type="object" shared="true">FiloBlu\Flow\Helper\CategoryHelper</argument>
        </arguments>
    </type>
    <type name="FiloBlu\Flow\Model\Actions\From\Removetocategory">
        <arguments>
            <argument name="categoryHelper" xsi:type="object" shared="true">FiloBlu\Flow\Helper\CategoryHelper</argument>
        </arguments>
    </type>
    <type name="FiloBlu\Flow\Model\Actions\From\Appendtocategory">
        <arguments>
            <argument name="categoryHelper" xsi:type="object" shared="true">FiloBlu\Flow\Helper\CategoryHelper</argument>
        </arguments>
    </type>
    <!-- Log -->
    <virtualType name="FiloBlu\Flow\Model\ResourceModel\Log\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">flow_log</argument>
            <argument name="resourceModel" xsi:type="string">FiloBlu\Flow\Model\ResourceModel\Log</argument>
        </arguments>
    </virtualType>

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="filoblu_flow_log_listing_data_source" xsi:type="string">FiloBlu\Flow\Model\ResourceModel\Log\Grid\Collection</item>
            </argument>
        </arguments>
    </type>

    <preference for="FiloBlu\Flow\Api\LogRepositoryInterface" type="FiloBlu\Flow\Model\LogRepository"/>
    <preference for="FiloBlu\Flow\Api\LogInterface" type="FiloBlu\Flow\Model\Log"/>

    <preference for="FiloBlu\Flow\Api\DocumentRepositoryInterface" type="FiloBlu\Flow\Model\DocumentRepository"/>
    <preference for="FiloBlu\Flow\Api\DocumentInterface" type="FiloBlu\Flow\Model\Document"/>

    <preference for="FiloBlu\Flow\Api\SwatchRepositoryInterface" type="FiloBlu\Flow\Model\SwatchRepository"/>
    <preference for="FiloBlu\Flow\Api\SwatchInterface" type="FiloBlu\Flow\Model\Swatch"/>

    <preference for="FiloBlu\Flow\Api\StockAdjustmentRepositoryInterface" type="FiloBlu\Flow\Model\StockAdjustmentRepository"/>
    <preference for="FiloBlu\Flow\Api\StockAdjustmentInterface" type="FiloBlu\Flow\Model\StockAdjustment"/>

    <preference for="FiloBlu\Flow\Api\StockAdjustmentManagerInterface" type="FiloBlu\Flow\Model\StockAdjustmentManager"/>

   <!--
   <type name="Magento\Framework\Logger\Monolog">
        <arguments>
            <argument name="name" xsi:type="string">main</argument>
            <argument name="handlers"  xsi:type="array">
                <item name="flow_db_logger" xsi:type="object">FiloBlu\Flow\Psr\Log\LogHandler</item>
            </argument>
        </arguments>
    </type>
    -->

    <!-- Special Actions -->

    <preference for="FiloBlu\Flow\Api\Data\SpecialActionPoolInterface" type="FiloBlu\Flow\Model\SpecialActionPool"/>
    <type name="FiloBlu\Flow\Model\SpecialActionPool">
        <arguments>
            <argument name="actions" xsi:type="array">

                <item name="_add_to_configurable" xsi:type="array">
                    <item name="name" xsi:type="string">_add_to_configurable</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_add_to_category_parent" xsi:type="array">
                    <item name="name" xsi:type="string">_add_to_category_parent</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_add_to_category" xsi:type="array">
                    <item name="name" xsi:type="string">_add_to_category</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_remove_to_category" xsi:type="array">
                    <item name="name" xsi:type="string">_remove_to_category</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_append_to_category" xsi:type="array">
                    <item name="name" xsi:type="string">_append_to_category</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_remove_all_crosssell" xsi:type="array">
                    <item name="name" xsi:type="string">_remove_all_crosssell</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_remove_all_upsell" xsi:type="array">
                    <item name="name" xsi:type="string">_remove_all_upsell</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_remove_all_related" xsi:type="array">
                    <item name="name" xsi:type="string">_remove_all_related</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_add_to_default" xsi:type="array">
                    <item name="name" xsi:type="string">_add_to_default</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">3</item>
                </item>

                <item name="_add_upsell" xsi:type="array">
                    <item name="name" xsi:type="string">_add_upsell</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">4</item>
                </item>

                <item name="_add_crosssell" xsi:type="array">
                    <item name="name" xsi:type="string">_add_crosssell</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">5</item>
                </item>

                <item name="_add_related" xsi:type="array">
                    <item name="name" xsi:type="string">_add_related</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">6</item>
                </item>

                <item name="_name" xsi:type="array">
                    <item name="name" xsi:type="string">_name</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">7</item>
                </item>

                <item name="_add_increment_stock" xsi:type="array">
                    <item name="name" xsi:type="string">_add_increment_stock</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">8</item>
                </item>

                <item name="_addwebsite" xsi:type="array">
                    <item name="name" xsi:type="string">_addwebsite</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_replacewebsite" xsi:type="array">
                    <item name="name" xsi:type="string">_replacewebsite</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_replaceparentwebsite" xsi:type="array">
                    <item name="name" xsi:type="string">_replaceparentwebsite</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_add_website" xsi:type="array">
                    <item name="name" xsi:type="string">_removewebsite</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_translate_attribute" xsi:type="array">
                    <item name="name" xsi:type="string">_translate_attribute</item>
                    <item name="executed_on" xsi:type="string">attribute</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_set_default_for_locale" xsi:type="array">
                    <item name="name" xsi:type="string">_set_default_for_locale</item>
                    <item name="executed_on" xsi:type="string">attribute</item>
                    <item name="priority" xsi:type="number">2</item>
                </item>

                <item name="_reassign_website" xsi:type="array">
                    <item name="name" xsi:type="string">_reassign_website</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_add_custom_option" xsi:type="array">
                    <item name="name" xsi:type="string">_add_custom_option</item>
                    <item name="executed_on" xsi:type="string">product</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_add_to_customer_group" xsi:type="array">
                    <item name="name" xsi:type="string">_add_to_customer_group</item>
                    <item name="executed_on" xsi:type="string">customer</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

                <item name="_add_to_customer_address" xsi:type="array">
                    <item name="name" xsi:type="string">_add_to_customer_address</item>
                    <item name="executed_on" xsi:type="string">customeraddress</item>
                    <item name="priority" xsi:type="number">1</item>
                </item>

            </argument>
        </arguments>
    </type>

    <type name="\FiloBlu\Flow\Model\From\Entity\Product">
        <arguments>
            <argument name="attributeMappedByValue" xsi:type="array">
                <item name="0" xsi:type="string">country_of_manufacture</item>
                <item name="1" xsi:type="string">status</item>
            </argument>
        </arguments>
    </type>

    <!-- PROXYS -->
    <type name="FiloBlu\Flow\Model\From\Stock">
        <arguments>
            <argument name="stock_qty" xsi:type="object">FiloBlu\Flow\Helper\Stock\Proxy</argument>
        </arguments>
    </type>

    <preference for="Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator" type="FiloBlu\Flow\Model\ProductUrlPathGenerator"/>

    <type name="FiloBlu\Flow\Model\Filters\BarcodeToSkuConverter" shared="true">
        <arguments>
            <argument name="productLookupHelper" xsi:type="object" shared="true">FiloBlu\Flow\Helper\ProductLookupHelper</argument>
        </arguments>
    </type>

    <type name="FiloBlu\Flow\Model\Filters\EanToSkuConverter" shared="true">
        <arguments>
            <argument name="productLookupHelper" xsi:type="object" shared="true">FiloBlu\Flow\Helper\ProductLookupHelper</argument>
        </arguments>
    </type>

    <!--Indexer Plugin -->
    <type name="Magento\Indexer\Model\Config\Data">
        <plugin name="filobluflowstockplugin" type="FiloBlu\Flow\Model\Indexer\Plugin\IndexerConfigData" />
    </type>


    <!-- Swatch Color -->
    <preference for="FiloBlu\Flow\Api\SwatchColorInterface" type="FiloBlu\Flow\Model\SwatchColor"/>



</config>
