<?xml version="1.0"?>
<!--
/**
 * Ebizmarts_MailChimp Magento JS component
 *
 * @category    Ebizmarts
 * @package     Ebizmarts_MailChimp
 * @author      Ebizmarts Team <info@ebizmarts.com>
 * @copyright   Ebizmarts (http://ebizmarts.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Ebizmarts\MailChimp\Block\Mailchimpjs">
        <arguments>
            <argument name="helper" xsi:type="object">Ebizmarts\MailChimp\Helper\Data\Proxy</argument>
        </arguments>
    </type>
    <type name="Magento\Quote\Model\Quote">
        <plugin name="mailchimp-save-quote" type="Ebizmarts\MailChimp\Model\Plugin\Quote" sortOrder="10"/>
    </type>
    <type name="Magento\Newsletter\Controller\Manage\Save">
        <plugin name="mailchimp-account-interest-group" type="Ebizmarts\MailChimp\Model\Plugin\Newsletter\Save" sortOrder="10"/>
    </type>
    <type name="Ebizmarts\MailChimp\Model\Logger\Handler">
        <arguments>
            <argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
        </arguments>
    </type>
    <type name="Ebizmarts\MailChimp\Model\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">MailChimpLogger</argument>
            <argument name="handlers"  xsi:type="array">
                <item name="system" xsi:type="object">Ebizmarts\MailChimp\Model\Logger\Handler</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Ebizmarts\MailChimp\Model\ResourceModel\MailChimpErrors\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">mailchimp_errors</argument>
            <argument name="resourceModel" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\MailChimpErrors</argument>
        </arguments>
    </virtualType>
    <virtualType name="Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatchesGrid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">mailchimp_sync_batches</argument>
            <argument name="resourceModel" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="mailchimp_errors_grid_data_source" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\MailChimpErrors\Collection</item>
                <item name="mailchimp_stores_grid_data_source" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores\Grid\Collection</item>
                <item name="mailchimp_batch_grid_data_source" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatchesGrid\Collection</item>
                <item name="mailchimp_cron_grid_data_source" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\Schedule\Collection</item>
                <item name="mailchimp_carts_grid_data_source" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\Carts\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">mailchimp_stores</argument>
            <argument name="resourceModel" xsi:type="string">Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Newsletter\Model\Subscriber">
        <plugin name="mailchimp-subscriber" type="Ebizmarts\MailChimp\Model\Plugin\Subscriber" sortOrder="10"/>
    </type>
    <type name="Magento\Newsletter\Model\SubscriptionManager">
        <plugin name="mailchimp-subscriptionmanager" type="Ebizmarts\MailChimp\Model\Plugin\SubscriptionManager" sortOrder="10"/>
    </type>
    <type name="Magento\Customer\Model\AccountManagement">
        <plugin name="abandoned-checkout-save-quote" type="Ebizmarts\MailChimp\Model\Plugin\AccountManagement" sortOrder="10"/>
    </type>
    <virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
        <arguments>
            <argument name="columns" xsi:type="array">
                <item name="mailchimp_flag" xsi:type="string">sales_order.mailchimp_flag</item>
            </argument>
        </arguments>
    </virtualType>
    <type name="Magento\SalesRule\Model\Coupon">
        <plugin name="mailchimp-coupon" type="Ebizmarts\MailChimp\Model\Plugin\Coupon" sortOrder="10"/>
    </type>
    <type name="Magento\Sales\Model\Order\Shipment">
        <plugin name="mailchimp_save_shipment" type="Ebizmarts\MailChimp\Model\Plugin\Ship" sortOrder="10"/>
    </type>
    <type name="Magento\Sales\Model\Order\Invoice">
        <plugin name="mailchimp_save_invoice" type="Ebizmarts\MailChimp\Model\Plugin\Invoice" sortOrder="10"/>
    </type>
    <type name="Magento\Sales\Model\Order\CreditmemoRepository">
        <plugin name="mailchimp_save_creditmemo" type="Ebizmarts\MailChimp\Model\Plugin\Creditmemo" sortOrder="10"/>
    </type>
    <preference for="Magento\Newsletter\Block\Subscribe" type="Ebizmarts\MailChimp\Block\Subscribe"/>
</config>
