<?xml version="1.0"?>
<!-- 
/**
 * Magetop Store
 *
 * @category  Magetop Extensions
 * @package   Magetop_Quotesystem
 * @author    Magetop Developer
 * @copyright Copyright (c) Magetop (https://www.magetop.com)
 * @license   https://www.magetop.com/license.html
 */
 -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<preference for="Magetop\Quotesystem\Api\Data\QuoteInterface" type="Magetop\Quotesystem\Model\Quotes" />
    <preference for="Magetop\Quotesystem\Api\Data\QuoteConversationInterface" type="Magetop\Quotesystem\Model\Quoteconversation" />
    <preference for="Magetop\Quotesystem\Api\QuoteRepositoryInterface" type="Magetop\Quotesystem\Model\QuoteRepository" />
    <preference for="Magento\Directory\Controller\Currency\SwitchAction" type="Magetop\Quotesystem\Controller\Rewrite\Currency\SwitchAction"/>
    <preference for="Magento\Checkout\Block\Cart\Sidebar" type="Magetop\Quotesystem\Block\Rewrite\Cart\Sidebar"/>
    <type name="Magento\Catalog\Block\Product\Compare\ListCompare">
        <plugin name="Magetop_Quotesystem::listcompare" type="Magetop\Quotesystem\Plugin\Catalog\Block\Product\Compare\ListCompare" sortOrder="1" />
    </type>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="mt_manage_quotes_data_source" xsi:type="string">Magetop\Quotesystem\Model\ResourceModel\Quotes\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Magetop\Quotesystem\Model\ResourceModel\Quotes\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">mt_quotes</argument>
            <argument name="eventPrefix" xsi:type="string">mt_quotes_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">mt_quotes_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">Magetop\Quotesystem\Model\ResourceModel\Quotes</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Quote\Model\Quote\Item">
        <plugin name="Magetop_Quotesystem::afterRepresentProduct" type="Magetop\Quotesystem\Model\Plugin\Quote\Item" sortOrder="1" />
    </type>
    <type name="Magento\Customer\Controller\Account\CreatePost">
        <plugin name="Magetop_Quotesystem::redirectAfterRegister" type="Magetop\Quotesystem\Plugin\Customer\Controller\Account\CreatePost" sortOrder="1" />
    </type>
    <type name="Magento\Checkout\Model\Cart">
        <plugin name="interceptAddingProductToCart" type="Magetop\Quotesystem\Plugin\Checkout\Model\Cart" sortOrder="10"/>
    </type>
    <type name="Magento\Multishipping\Model\Checkout\Type\Multishipping">
        <plugin name="interceptUpdatingProduct" type="Magetop\Quotesystem\Plugin\Checkout\Multishipping" sortOrder="10"/>
    </type>
    <type name="Magetop\Quotesystem\Ui\Component\MassAction\Status\QuoteOptions">
        <arguments>
            <argument name="data" xsi:type="array">
                <item name="urlPath" xsi:type="string">quotesystem/managequotes/massUpdate</item>
                <item name="paramName" xsi:type="string">quoteupdate</item>
                <item name="confirm" xsi:type="array">
                    <item name="title" xsi:type="string" translatable="true">Quote Status</item>
                    <item name="message" xsi:type="string" translatable="true">Are you sure you want to update status of selected quotes?</item>
                </item>
            </argument>
        </arguments>
    </type>
    <!-- feature update -->
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="mt_view_quotes_data_source" xsi:type="string">Magetop\Quotesystem\Model\ResourceModel\QuoteDetails\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Magetop\Quotesystem\Model\ResourceModel\QuoteDetails\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">mt_quote_details</argument>
            <argument name="eventPrefix" xsi:type="string">mt_quote_details_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">mt_quote_details_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">Magetop\Quotesystem\Model\ResourceModel\QuoteDetails</argument>
        </arguments>
    </virtualType>

    <preference for="Magetop\Quotesystem\Api\QuoteDetailsRepositoryInterface" type="Magetop\Quotesystem\Model\QuoteDetailsRepository" />
	<preference for="Magetop\Quotesystem\Api\Data\QuoteDetailsInterface" type="Magetop\Quotesystem\Model\QuoteDetails" />
    <preference for="Magento\Quote\Model\Quote\Address\Total\Subtotal" type="Magetop\Quotesystem\Model\Quote\Address\Total\Subtotal"/>
</config>
