<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Pre Order Base for Magento 2
 */-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="amastyPreorder" xsi:type="array">
                    <item name="class" xsi:type="string">Amasty\Preorder\Ui\DataProvider\Product\Form\Modifier\Preorder</item>
                    <item name="sortOrder" xsi:type="number">30</item>
                </item>
            </argument>
        </arguments>
    </virtualType>

    <type name="Magento\InventoryIndexer\Indexer\SourceItem\Strategy\Sync">
        <plugin name="Amasty_Preorder::preorder-reindex-msi" type="Amasty\Preorder\Plugin\InventoryIndexer\Indexer\SourceItem\Strategy\Sync\ReindexPreorder" />
    </type>

    <type name="Magento\Sales\Model\ResourceModel\Order\Grid\Collection">
        <plugin name="Amasty_Preorder::join-preorder-data" type="Amasty\Preorder\Plugin\Sales\Model\ResourceModel\Order\Grid\Collection\JoinPreorderData" />
        <plugin name="Amasty_Preorder::apply-preorder-filter" type="Amasty\Preorder\Plugin\Sales\Model\ResourceModel\Order\Grid\Collection\ApplyPreorderFilter" />
    </type>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter">
        <plugin name="Amasty_Preorder::join-preorder-table" type="Amasty\Preorder\Plugin\Sales\Model\ResourceModel\Order\Grid\Collection\JoinPreorderTableToExport"/>
    </type>

    <type name="Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab\Inventory">
        <plugin name="Amasty_Preorder::addPreOrderFields" type="Amasty\Preorder\Plugin\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab\Inventory\AddPreorderTab" />
    </type>

    <type name="Magento\SalesRule\Model\Rule\Condition\Product\Combine">
        <plugin name="Amasty_Preorder::addPreorderCondition" type="Amasty\Preorder\Plugin\SalesRule\Model\Rule\Condition\Product\Combine\AddPreorderCondition" />
    </type>
    <type name="Magento\CatalogRule\Model\Rule\Condition\Combine">
        <plugin name="Amasty_Preorder::addPreorderCondition" type="Amasty\Preorder\Plugin\CatalogRule\Model\Rule\Condition\Combine\AddPreorderCondition" />
    </type>
    <type name="Amasty\Stockstatus\Model\Rule\Condition\Combine">
        <plugin name="Amasty_Preorder::addPreorderCondition" type="Amasty\Preorder\Plugin\Stockstatus\Model\Rule\Condition\Combine\AddPreorderCondition" />
    </type>

    <virtualType name="AmastyPreOrderCustomStatusPromo" type="Amasty\Base\Block\Adminhtml\System\Config\Form\Field\Promo\PromoField">
        <arguments>
            <argument name="moduleName" xsi:type="string">Amasty_PreOrderCustomStatus</argument>
            <argument name="promoConfig" xsi:type="array">
                <item name="promoLink" xsi:type="string"><![CDATA[https://amasty.com/amcustomer/account/products/?utm_source=extension&utm_medium=backend&utm_campaign=subscribe_preorder]]></item>
                <item name="comment" xsi:type="string"><![CDATA[The functionality is available as part of an active product subscription or support subscription in Pre-Order Pro version. To upgrade and obtain functionality, please follow the <a href='https://amasty.com/amcustomer/account/products/?utm_source=extension&utm_medium=backend&utm_campaign=subscribe_preorder' target='_blank'>link</a>. Then you can find the 'amasty/module-pre-order-custom-status' package for installation in composer suggest.]]></item>
            </argument>
        </arguments>
    </virtualType>
</config>
