Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove previous DI that was erratic for virtual categories and also u… #368

Merged
merged 1 commit into from
Mar 23, 2017

Conversation

romainruaud
Copy link
Collaborator

@romainruaud romainruaud commented Mar 23, 2017

…module to prevent explicit application of category filter.

This is related to #367 and #366 .

When enforcing the catalogsearch layer to be used on catalog navigation, we introduced a biasis causing to always apply the addCategoryFilter method on the product collection.

This causes all categories to include a "must category_id=XXX" which indeed works for standard categories but produces conditions like "must color=blue AND category_id=XXX" on virtual categories which is not reliable.

It also causes a double appliance of "category_id=XXX" on standard category but does not fail since it does not change anything to the result.

=> This was NOT necessary since I tested again without this DI and here are my results :

        $this->catalogLayer = $layerResolver->get();
        $collection = $this->catalogLayer->getProductCollection();
        $collection->addIsInStockFilter();

        $logger->info(" Class : " . get_class($collection));

Outputs no error and :

Class : Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection\Interceptor

This is due to Magento behavioring good via the catalogsearch module DI :

    <virtualType name="Magento\CatalogSearch\Model\Layer\Category\Context" type="Magento\Catalog\Model\Layer\Category\Context">
        <arguments>
            <argument name="collectionProvider" xsi:type="object">Magento\CatalogSearch\Model\Layer\Category\ItemCollectionProvider</argument>
        </arguments>
    </virtualType>

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

@afoucret afoucret merged commit 997130d into Smile-SA:2.3.x Mar 23, 2017
@romainruaud romainruaud deleted the fix_virtual-categories-layer branch April 19, 2017 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants