<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Shop by Brand 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\Framework\App\RouterList">
        <arguments>
            <argument name="routerList" xsi:type="array">
                <item name="amasty_shopby_brand" xsi:type="array">
                    <item name="class" xsi:type="string">Amasty\ShopbyBrand\Controller\Router</item>
                    <item name="disable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="string">40</item>
                </item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
        <plugin name="Amasty_ShopbyBrand::changeCategoryForUrlRewrites"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Model\ResourceModel\Product\Collection\FixUrlRewrites"/>
    </type>
    <type name="Magento\Catalog\Model\Layer\State">
        <plugin name="Amasty_ShopbyBrand::ExcludeBrandFilterFromStage"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Model\Layer\State"/>
    </type>
    <type name="Magento\Theme\Block\Html\Topmenu">
        <plugin name="Amasty_ShopbyBrand::TopMenuFirst"
                type="Amasty\ShopbyBrand\Plugin\Block\Html\Topmenu" sortOrder="-1" />
        <plugin name="Amasty_ShopbyBrand::TopMenuLast"
                type="Amasty\ShopbyBrand\Plugin\Block\Html\TopmenuLast" sortOrder="999" />
    </type>
    <type name="Infortis\UltraMegamenu\Block\Navigation">
        <plugin name="Amasty_ShopbyBrand::TopMenuUltimo"
                type="Amasty\ShopbyBrand\Plugin\Block\Html\TopmenuThemes" sortOrder="999" />
    </type>
    <type name="Smartwave\Megamenu\Block\Topmenu">
        <plugin name="Amasty_ShopbyBrand::TopMenuPorto"
                type="Amasty\ShopbyBrand\Plugin\Block\Html\TopmenuThemes" sortOrder="999" />
    </type>
    <type name="Amasty\MegaMenuLite\Model\Menu\TreeResolver">
        <plugin name="Amasty_ShopbyBrand::Amasty_MegaMenu"
                type="Amasty\ShopbyBrand\Plugin\Block\Html\MegaMenu" sortOrder="999" />
    </type>
    <type name="Amasty\ShopbyBase\Model\Customizer\Category">
        <arguments>
            <argument name="customizers" xsi:type="array">
                <item name="brand" xsi:type="string">\Amasty\ShopbyBrand\Model\Customizer\Category\Brand</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Theme\Block\Html\Title">
        <plugin name="Amasty_ShopbyBrand::linksTitle"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Block\Product\View\BlockHtmlTitlePlugin" />
    </type>
    <type name="Amasty\Mage24Fix\Block\Theme\Html\Title">
        <plugin name="Amasty_ShopbyBrand::linksTitle"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Block\Product\View\BlockHtmlTitlePlugin" />
    </type>

    <type name="Amasty\Shopby\Model\Layer\Filter\Attribute">
        <plugin name="remove-brand-from-filter" type="Amasty\ShopbyBrand\Plugin\AttributeFilterPlugin"/>
    </type>
    <type name="Amasty\Shopby\Model\Layer\Filter\Resolver\FilterRequestDataResolver">
        <plugin name="remove-brand-from-filter" type="Amasty\ShopbyBrand\Plugin\Shopby\Model\Layer\Filter\Resolver\FilterRequestDataResolver\HideBrandFilterOnBrandPage"/>
    </type>

    <type name="Amasty\ShopbySeo\Helper\Url">
        <plugin name="Amasty_ShopbyBrand::urlBuilderSeo" type="Amasty\ShopbyBrand\Plugin\ShopbySeo\Helper\Url" />
    </type>

    <type name="Magento\Catalog\Block\Product\ListProduct">
        <plugin name="Amasty_ShopbyBrand::show_logo_on_listing"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Block\Product\ListProduct\AddBrandIconForProduct" />
    </type>

    <virtualType name="Magento\CatalogSearch\Block\SearchResult\ListProduct">
        <plugin name="Amasty_ShopbyBrand::show_logo_on_listing_search"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Block\Product\ListProduct\AddBrandIconForProduct" />
    </virtualType>

    <type name="Amasty\Mostviewed\Block\Widget\Related">
        <plugin name="Amasty_ShopbyBrand::add_to_related"
                type="Amasty\ShopbyBrand\Plugin\Catalog\Block\Product\ListProduct\AddBrandIconForProduct" />
    </type>

    <type name="Amasty\ShopbySeo\Controller\Router">
        <plugin name="Amasty_ShopbyBrand::SkipSeoRequestModification"
                type="Amasty\ShopbyBrand\Plugin\ShopbySeo\Controller\Router" />
        <plugin name="Amasty_ShopbyBrand::DontSkipBrandUrl"
                type="Amasty\ShopbyBrand\Plugin\ShopbySeo\Controller\Router\CheckForBrandUrl" />
    </type>

    <type name="Amasty\ShopbyBase\Model\UrlBuilder">
        <arguments>
            <argument name="urlAdapters" xsi:type="array">
                <item name="brand" xsi:type="array">
                    <item name="adapter" xsi:type="object">Amasty\ShopbyBrand\Model\UrlBuilder\Adapter</item>
                    <item name="sort_order" xsi:type="string">10</item>
                </item>
            </argument>
        </arguments>
    </type>

    <type name="Amasty\ShopbyBrand\Controller\Index\Index">
        <arguments>
            <argument name="categoryManager" xsi:type="object">Amasty\ShopbyBase\Model\Category\Manager\Proxy</argument>
        </arguments>
    </type>

    <type name="Magento\CatalogStaging\Model\ResourceModel\Fulltext\Collection">
        <arguments>
            <argument name="searchCriteriaBuilder" xsi:type="object">Magento\Framework\Api\Search\SearchCriteriaBuilder</argument>
        </arguments>
    </type>

    <type name="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection">
        <arguments>
            <argument name="searchCriteriaBuilder" xsi:type="object">Magento\Framework\Api\Search\SearchCriteriaBuilder</argument>
        </arguments>
    </type>

    <type name="Amasty\ShopbySeo\Model\SeoOptions">
        <plugin name="Amasty_ShopbyBrand::CutBrandAttribute"
                type="Amasty\ShopbyBrand\Plugin\ShopbySeo\Model\SeoOptions\CutBrandAttribute" />
    </type>

    <type name="Magento\Store\ViewModel\SwitcherUrlProvider">
        <plugin name="Amasty_ShopbyBrand::ResolveBrandUrl"
                type="Amasty\ShopbyBrand\Plugin\Store\ViewModel\SwitcherUrlProvider\ResolveBrandUrl" sortOrder="990"/>
    </type>
    <type name="Amasty\ShopbyBrand\Plugin\Store\ViewModel\SwitcherUrlProvider\ResolveBrandUrl">
        <arguments>
            <argument name="urlAdapter" xsi:type="object">Amasty\ShopbyBrand\Model\UrlBuilder\Adapter</argument>
        </arguments>
    </type>

    <type name="Magento\Framework\Search\Dynamic\Algorithm" shared="false" />

    <type name="Amasty\ElasticSearch\Model\Search\GetRequestQuery\GetAggregations">
        <plugin name="Amasty_ShopbyBrand::SetBrandBucketSize"
                type="Amasty\ShopbyBrand\Plugin\ElasticSearch\Model\Search\GetRequestQuery\GetAggregations\SetBrandBucketSize" />
    </type>
    <type name="Magento\Elasticsearch\SearchAdapter\Query\Builder\Aggregation">
        <plugin name="Amasty_ShopbyBrand::SetBrandBucketSize"
                type="Amasty\ShopbyBrand\Plugin\Elasticsearch\SearchAdapter\Query\Builder\Aggregation\SetBrandBucketSize" />
    </type>
</config>
