<?xml version="1.0"?>
<!--
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_ProductLabels
 * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Mageplaza\ProductLabels\Api\LabelRepositoryInterface" type="Mageplaza\ProductLabels\Model\LabelRepository" />
    <preference for="Mageplaza\ProductLabels\Api\Data\LabelInterface" type="Mageplaza\ProductLabels\Model\Rule" />
    <preference for="Mageplaza\ProductLabels\Api\Data\LabelSearchResultInterface" type="Magento\Framework\Api\SearchResults"/>

    <type name="Magento\Framework\Console\CommandList">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="mpproductlabel_command_applyrule" xsi:type="object">Mageplaza\ProductLabels\Console\ApplyRule</item>
            </argument>
        </arguments>
    </type>

    <type name="Mageplaza\ProductLabels\Model\ResourceModel\Rule\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">mageplaza_productlabels_rule</argument>
            <argument name="resourceModel" xsi:type="string">Mageplaza\ProductLabels\Model\ResourceModel\Rule</argument>
        </arguments>
    </type>
    <type name="Magento\Catalog\Block\Category\View">
        <plugin name="mpproductlabels_ajax_update" type="Mageplaza\ProductLabels\Plugin\Block\Category\View" sortOrder="1"/>
    </type>
    <virtualType name="Magento\CatalogSearch\Block\Result">
        <plugin name="catalog_search_after_list_product" type="Mageplaza\ProductLabels\Plugin\Block\Result"/>
    </virtualType>
    <type name="Magento\Catalog\Block\Product\ListProduct">
        <plugin name="mpproductlabels_catalog_listing_labels" type="Mageplaza\ProductLabels\Plugin\Listing\Label"/>
    </type>
    <virtualType name="Magento\CatalogSearch\Block\SearchResult\ListProduct">
        <plugin name="catalog_search_listing_labels" type="Mageplaza\ProductLabels\Plugin\Listing\Label"/>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="mpproductlabels_rule_listing_data_source" xsi:type="string">Mageplaza\ProductLabels\Model\ResourceModel\Rule\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Catalog\Api\Data\ProductInterface">
        <plugin name="ProductExtensionAttributeOperations" type="Mageplaza\ProductLabels\Plugin\ProductAttributesLoad"/>
    </type>
    <type name="Magento\Catalog\Api\ProductRepositoryInterface">
        <plugin name="add_label_attributes_to_product" type="Mageplaza\ProductLabels\Plugin\Api\LabelAttributes" sortOrder="60"/>
    </type>
    <type name="Magento\Catalog\Block\Product\AbstractProduct">
        <plugin name="mpproductlabels_product" type="Mageplaza\ProductLabels\Plugin\Block\AbstractProduct" />
    </type>
    <type name="Magento\Checkout\Block\Cart\Item\Renderer">
        <plugin name="mpproductlabels_checkout_cart_labels" type="Mageplaza\ProductLabels\Plugin\Block\Cart\Item\Label"/>
    </type>
    <type name="Magento\Checkout\CustomerData\AbstractItem">
        <plugin name="mpproductlabels_checkout_minicart_labels" type="Mageplaza\ProductLabels\Plugin\CustomerData\AbstractItem"/>
    </type>
</config>
