<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Customer Group Catalog for Magento 2
 */-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\ResourceModel\Product">
        <plugin name="apply_amasty_groupcat_rules_after_product_save" type="Amasty\Groupcat\Plugin\Indexer\Product\Save\ApplyRules"/>
    </type>
    <type name="Magento\Catalog\Model\Category">
        <plugin name="apply_amasty_groupcat_rules_after_products_assign" type="Amasty\Groupcat\Plugin\Indexer\Category"/>
    </type>
    <type name="Magento\Store\Model\Store">
        <plugin name="reindex_amasty_groupcat_rules_after_delete_store" type="Amasty\Groupcat\Plugin\Indexer\Store"/>
    </type>
    <type name="Magento\Customer\Model\Group">
        <plugin name="reindex_amasty_groupcat_rules_after_delete_customer_group" type="Amasty\Groupcat\Plugin\Indexer\CustomerGroup"/>
    </type>
    <type name="Magento\ImportExport\Model\Import">
        <plugin name="reindex_amasty_groupcat_rules_after_import" type="Amasty\Groupcat\Plugin\Indexer\ImportExport"/>
    </type>
    <type name="Magento\Catalog\Model\ResourceModel\Eav\Attribute">
        <plugin name="change_product_attribute" type="Amasty\Groupcat\Plugin\Indexer\Product\Attribute"/>
    </type>
    <type name="Magento\Customer\Model\ResourceModel\Attribute">
        <plugin name="change_customer_attribute" type="Amasty\Groupcat\Plugin\Indexer\Customer\Attribute"/>
    </type>

    <virtualType name="Amasty\Groupcat\Ui\Component\Listing\Column\Store" type="Magento\Store\Ui\Component\Listing\Column\Store">
        <arguments>
            <argument name="storeKey" xsi:type="string">store_ids</argument>
        </arguments>
    </virtualType>

    <virtualType name="amGroupcatStockIndexTableNameResolver" type="Amasty\Groupcat\Model\Di\Wrapper">
        <arguments>
            <argument name="name" xsi:type="string">Magento\InventoryIndexer\Model\StockIndexTableNameResolverInterface</argument>
            <argument name="isProxy" xsi:type="boolean">true</argument>
        </arguments>
    </virtualType>

    <virtualType name="amGroupcatGetStockIdForCurrentWebsite" type="Amasty\Groupcat\Model\Di\Wrapper">
        <arguments>
            <argument name="name" xsi:type="string">Magento\InventoryCatalog\Model\GetStockIdForCurrentWebsite</argument>
            <argument name="isProxy" xsi:type="boolean">true</argument>
        </arguments>
    </virtualType>

    <type name="Amasty\Groupcat\Model\ResourceModel\InventoryResolver">
        <arguments>
            <argument name="stockIndexTableNameResolver" xsi:type="object">amGroupcatStockIndexTableNameResolver</argument>
            <argument name="getStockIdForCurrentWebsite" xsi:type="object">amGroupcatGetStockIdForCurrentWebsite</argument>
        </arguments>
    </type>
</config>
