Smile-SA/elasticsuite

View on GitHub
src/module-elasticsuite-catalog-graph-ql/etc/graphql/di.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0"?>
<!--
/**
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
 * versions in the future.
 *
 * @category  Smile
 * @package   Smile\ElasticsuiteCatalogGraphQl
 * @author    Romain Ruaud <romain.ruaud@smile.fr>
 * @copyright 2020 Smile
 * @license   Open Software License ("OSL") v. 3.0
 */
 -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\CatalogGraphQl\DataProvider\Product\SearchCriteriaBuilder"
        type="Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\SearchCriteriaBuilder"/>
    <preference for="Magento\CatalogGraphQl\Model\Resolver\Products" type="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Products" />
    <preference for="Magento\CatalogGraphQl\Model\Resolver\Products\Query\ProductQueryInterface" type="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Products\Query\Search"/>
    <preference for="Magento\CatalogGraphQl\Model\Resolver\Products\SearchResult" type="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Products\SearchResult"/>

    <virtualType name="elasticsuiteSearchResultApplier" type="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierFactory">
        <arguments>
            <argument name="instanceName" xsi:type="string">Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection\SearchResultApplier</argument>
        </arguments>
    </virtualType>

    <type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\ProductSearch">
        <arguments>
            <argument name="searchResultsApplierFactory" xsi:type="object">elasticsuiteSearchResultApplier</argument>
        </arguments>
    </type>

    <!-- 'aggregations' Data Providers -->
    <preference for="Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Attribute"
                type="Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Attribute"/>
    <preference for="Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Category"
                type="Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Category"/>
    <preference for="Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Price"
                type="Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Price"/>

    <type name="Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\LayerBuilder">
        <arguments>
            <argument name="builders" xsi:type="array">
                <item name="category_uid_bucket" xsi:type="object">Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\CategoryUid</item>
            </argument>
        </arguments>
    </type>

    <!-- Layer filters implementation -->
    <virtualType name="Smile\ElasticsuiteCatalogGraphQl\Model\ResourceModel\Product\SearchResultCollectionFactory"
                 type="Magento\Catalog\Model\ResourceModel\Product\CollectionFactory">
        <arguments>
            <argument name="instanceName" xsi:type="string">Smile\ElasticsuiteCatalogGraphQl\Model\ResourceModel\Product\SearchResultCollection</argument>
        </arguments>
    </virtualType>

    <type name="Smile\ElasticsuiteCatalogGraphQl\Model\Layer\CollectionProvider">
        <arguments>
            <argument name="collectionFactory" xsi:type="object">Smile\ElasticsuiteCatalogGraphQl\Model\ResourceModel\Product\SearchResultCollectionFactory</argument>
        </arguments>
    </type>

    <type name="Magento\CatalogGraphQl\Model\Layer\Context">
        <arguments>
            <argument name="collectionProvider" xsi:type="object">Smile\ElasticsuiteCatalogGraphQl\Model\Layer\CollectionProvider</argument>
        </arguments>
    </type>

    <type name="Magento\Catalog\Model\Layer\Search">
        <arguments>
            <argument name="context" xsi:type="object">Magento\CatalogGraphQl\Model\Layer\Context</argument>
        </arguments>
    </type>

    <type name="Magento\Catalog\Model\Layer\Category">
        <arguments>
            <argument name="context" xsi:type="object">Magento\CatalogGraphQl\Model\Layer\Context</argument>
        </arguments>
    </type>

    <virtualType name="smileEScategoryFilterableAttributesCollection" type="Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory">
        <arguments>
            <argument name="instanceName" xsi:type="string">Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\FilterableAttribute\Category\Collection</argument>
        </arguments>
    </virtualType>

    <type name="Smile\ElasticsuiteCatalog\Model\Layer\Category\FilterableAttributeList">
        <arguments>
            <argument name="collectionFactory" xsi:type="object">smileEScategoryFilterableAttributesCollection</argument>
        </arguments>
    </type>

    <virtualType name="categoryFilterList" type="Smile\ElasticsuiteCatalog\Model\Layer\FilterList">
        <arguments>
            <argument name="filterableAttributes" xsi:type="object">Smile\ElasticsuiteCatalog\Model\Layer\Category\FilterableAttributeList</argument>
            <argument name="filters" xsi:type="array">
                <item name="attribute" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Attribute</item>
                <item name="price" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Price</item>
                <item name="decimal" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Decimal</item>
                <item name="category" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Category</item>
                <item name="boolean" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Boolean</item>
            </argument>
        </arguments>
    </virtualType>

    <virtualType name="searchFilterList" type="Smile\ElasticsuiteCatalog\Model\Layer\FilterList">
        <arguments>
            <argument name="filterableAttributes" xsi:type="object">Smile\ElasticsuiteCatalog\Model\Layer\Search\FilterableAttributeList</argument>
            <argument name="filters" xsi:type="array">
                <item name="attribute" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Attribute</item>
                <item name="price" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Price</item>
                <item name="decimal" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Decimal</item>
                <item name="category" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Category</item>
                <item name="boolean" xsi:type="string">Smile\ElasticsuiteCatalog\Model\Layer\Filter\Boolean</item>
            </argument>
        </arguments>
    </virtualType>

    <type name="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Layer\FiltersProvider">
        <arguments>
            <argument name="filtersList" xsi:type="array">
                <item name="search" xsi:type="object">searchFilterList</item>
                <item name="category" xsi:type="object">categoryFilterList</item>
            </argument>
        </arguments>
    </type>

    <preference for="Magento\CatalogGraphQl\Model\Resolver\Layer\FiltersProvider" type="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Layer\FiltersProvider"/>

    <type name="Magento\CatalogGraphQl\Model\Resolver\LayerFilters">
        <plugin name="search_results_aggregations" type="Smile\ElasticsuiteCatalogGraphQl\Plugin\Resolver\LayerFilters"/>
    </type>

    <!-- Layered navigation filtering : Aggregation building and modifying -->
    <type name="\Smile\ElasticsuiteCatalog\Search\Request\Product\Aggregation\Provider\FilterableAttributes\Modifier\Coverage">
        <arguments>
            <argument name="coverageRequestBuilder" xsi:type="object">\Smile\ElasticsuiteCatalog\Search\Request\Product\Coverage\Builder</argument>
        </arguments>
    </type>

    <type name="\Smile\ElasticsuiteCatalog\Search\Request\Product\Aggregation\Provider\FilterableAttributes">
        <arguments>
            <argument name="modifiersPool" xsi:type="array">
                <item name="coverageModifier" xsi:type="object">Smile\ElasticsuiteCatalog\Search\Request\Product\Aggregation\Provider\FilterableAttributes\Modifier\Coverage</item>
            </argument>
        </arguments>
    </type>

    <virtualType name="elasticsuiteCollectionPreProcessor" type="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CompositeCollectionProcessor">
        <arguments>
            <argument name="collectionProcessors" xsi:type="array">
                <item name="search" xsi:type="object">Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor\SearchCriteriaProcessor</item>
            </argument>
        </arguments>
    </virtualType>

    <virtualType name="elasticsuiteProductProvider" type="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\ProductSearch">
        <arguments>
            <argument name="collectionPreProcessor" xsi:type="object">elasticsuiteCollectionPreProcessor</argument>
        </arguments>
    </virtualType>

    <type name="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Products\Query\Search">
        <arguments>
            <argument name="productProvider" xsi:type="object">elasticsuiteProductProvider</argument>
        </arguments>
    </type>

    <preference for="Magento\CatalogGraphQl\Model\Resolver\Aggregations" type="Smile\ElasticsuiteCatalogGraphQl\Model\Resolver\Aggregations"/>

    <type name="\Smile\ElasticsuiteCatalog\Search\Request\Product\Aggregation\Provider\FilterableAttributes">
        <arguments>
            <argument name="modifiersPool" xsi:type="array">
                <item name="viewMoreFilterModifier" xsi:type="object">Smile\ElasticsuiteCatalogGraphQl\Search\Request\Product\Aggregation\Provider\FilterableAttributes\Modifier\ViewMore</item>
            </argument>
        </arguments>
    </type>

    <type name="Smile\ElasticsuiteCatalog\Search\Request\Product\Attribute\AggregationInterface">
        <plugin name="layered_nav_attributes_replace_filter_field"
                type="Smile\ElasticsuiteCatalog\Plugin\Search\Request\Product\Attribute\Aggregation\LayeredNavAttribute"/>
    </type>
</config>