Skip to content

Commit

Permalink
Merge pull request #1461 from romainruaud/fix_mage232-layered-navigation
Browse files Browse the repository at this point in the history
Fix layered navigation with Magento 2.3.2
  • Loading branch information
romainruaud authored Jul 8, 2019
2 parents f136c0f + 0dd33b5 commit b46ddb7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
17 changes: 5 additions & 12 deletions src/module-elasticsuite-catalog/Plugin/LayerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
*/
namespace Smile\ElasticsuiteCatalog\Plugin;

use Magento\CatalogInventory\Model\Plugin\Layer;

/**
* Replace is in stock native filter on layer.
* Prepare collection sort orders.
*
* @category Smile
* @package Smile\ElasticsuiteCatalog
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr>
*/
class LayerPlugin extends \Magento\CatalogInventory\Model\Plugin\Layer
class LayerPlugin
{
/**
* @var \Magento\Search\Model\QueryFactory
Expand All @@ -44,20 +42,15 @@ class LayerPlugin extends \Magento\CatalogInventory\Model\Plugin\Layer
/**
* Constructor.
*
* @param \Magento\CatalogInventory\Helper\Stock $stockHelper Stock helper.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig Configuration.
* @param \Magento\Search\Model\QueryFactory $queryFactory Search query factory.
* @param \Magento\Catalog\Model\Config $catalogConfig Catalog Configuration.
* @param \Smile\ElasticsuiteCore\Helper\Mapping $mappingHelper Mapping Helper.
* @param \Magento\Search\Model\QueryFactory $queryFactory Search query factory.
* @param \Magento\Catalog\Model\Config $catalogConfig Catalog Configuration.
* @param \Smile\ElasticsuiteCore\Helper\Mapping $mappingHelper Mapping Helper.
*/
public function __construct(
\Magento\CatalogInventory\Helper\Stock $stockHelper,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Search\Model\QueryFactory $queryFactory,
\Magento\Catalog\Model\Config $catalogConfig,
\Smile\ElasticsuiteCore\Helper\Mapping $mappingHelper
) {
parent::__construct($stockHelper, $scopeConfig);
$this->queryFactory = $queryFactory;
$this->catalogConfig = $catalogConfig;
$this->mappingHelper = $mappingHelper;
Expand Down
33 changes: 32 additions & 1 deletion src/module-elasticsuite-catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@
</arguments>
</virtualType>

<!-- Layer related configurations -->
<type name="Magento\Catalog\Model\Layer">
<plugin name="addStockStatusOnPrepareFrontCollection" type="Smile\ElasticsuiteCatalog\Plugin\LayerPlugin"/>
<plugin name="createSortOrdersOnPrepareFrontCollection" type="Smile\ElasticsuiteCatalog\Plugin\LayerPlugin"/>
</type>

<virtualType name="Magento\CatalogSearch\Model\Layer\Category\Context" type="Magento\Catalog\Model\Layer\Category\Context">
Expand All @@ -123,7 +124,37 @@
<argument name="stateKey" xsi:type="object">Magento\CatalogSearch\Model\Layer\Search\StateKey</argument>
</arguments>
</virtualType>

<!-- Since Magento 2.3.2 -->

<!-- Enforce Elasticsuite context (virtualType defined above) into the Layer. Otherwise the Magento_Elasticsearch module would take precedence -->
<type name="Magento\Catalog\Model\Layer\Search">
<arguments>
<argument name="context" xsi:type="object">Magento\CatalogSearch\Model\Layer\Search\Context</argument>
</arguments>
</type>
<type name="Magento\Catalog\Model\Layer\Category">
<arguments>
<argument name="context" xsi:type="object">Magento\CatalogSearch\Model\Layer\Category\Context</argument>
</arguments>
</type>
<!-- End of enforcing context. -->

<!-- Ensure proper collection for Advanced Search -->
<type name="Magento\CatalogSearch\Model\Search\ItemCollectionProvider">
<arguments>
<argument name="factories" xsi:type="array">
<!-- This collection is a virtual type -->
<item name="elasticsuite" xsi:type="object">Magento\CatalogSearch\Model\ResourceModel\Advanced\CollectionFactory</item>
</argument>
</arguments>
</type>
<!-- End of proper collection for Advanced Search -->

<!-- End since Magento 2.3.2 -->

<!-- End Layer related configuration -->

<type name="Magento\CatalogSearch\Block\Result">
<plugin name="smile_es_spellchecker" type="Smile\ElasticsuiteCatalog\Block\Plugin\ResultPlugin" />
</type>
Expand Down
1 change: 1 addition & 0 deletions src/module-elasticsuite-catalog/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<module name="Magento_InventorySalesApi" />
<module name="Magento_InventorySales" />
<module name="Magento_InventoryIndexer" />
<module name="Magento_Elasticsearch" />
</sequence>
</module>
</config>

2 comments on commit b46ddb7

@sbodak
Copy link

@sbodak sbodak commented on b46ddb7 Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romainruaud Can you run an update on packagist?

@romainruaud
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbodak : Packagist is up-to-date with Elasticsuite 2.8.x-dev branch.

You'll have to wait a bit more for the 2.8.1 stable version because we have now to backtest it internally to ensure delivering a properly working version.

Regards

Please sign in to comment.