<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="DJOGlobal\ProviderPricing\Api\ProviderPricingRepositoryInterface" type="DJOGlobal\ProviderPricing\Model\ProviderPricingRepository"/>
    <preference for="DJOGlobal\ProviderPricing\Api\Data\ProviderPricingInterface" type="DJOGlobal\ProviderPricing\Model\ProviderPricing"/>
    <preference for="DJOGlobal\ProviderPricing\Api\Data\ProviderPricingSearchResultsInterface" type="Magento\Framework\Api\SearchResults"/>

    <preference for="Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProviderInterface" type="DJOGlobal\ProviderPricing\Rewrite\Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProvider"/>

    <virtualType name="Magento\Catalog\Pricing\Price\Pool" type="Magento\Framework\Pricing\Price\Pool">
        <arguments>
            <argument name="prices" xsi:type="array">
                <item name="provider_price" xsi:type="string">DJOGlobal\ProviderPricing\Pricing\Price\ProviderPrice</item>
            </argument>
        </arguments>
    </virtualType>

    <!-- to help find the simple with the lowest provider price calculated price -->
    <type name="Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderComposite">
        <arguments>
            <argument name="linkedProductSelectBuilder" xsi:type="array">
                <item name="providerPrice" xsi:type="object">DJOGlobal\ProviderPricing\Model\ResourceModel\Product\LinkedProductSelectBuilderByProviderPrice</item>
            </argument>
        </arguments>
    </type>

    <!-- admin grid -->

    <virtualType name="DJOGlobalProviderPricingGridFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>

    <virtualType name="DJOGlobalProviderPricingGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">DJOGlobal\ProviderPricing\Model\ResourceModel\ProviderPricing\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">DJOGlobalProviderPricingGridFilterPool</argument>
        </arguments>
    </virtualType>

    <type name="DJOGlobal\ProviderPricing\Model\ResourceModel\ProviderPricing\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">djo_provider_pricing</argument>
            <argument name="eventPrefix" xsi:type="string">djo_provider_pricing_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">provider_pricing_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">DJOGlobal\ProviderPricing\Model\ResourceModel\providerPricing</argument>
        </arguments>
    </type>

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="djoglobal_provider_pricing_listing_data_source" xsi:type="string">DJOGlobal\ProviderPricing\Model\ResourceModel\ProviderPricing\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
</config>
