Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
magento 2.1, 2.2 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Zhavoronkov committed Oct 12, 2017
1 parent a78c53a commit cfa78e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<?php
namespace Niks\LayeredNavigation\Model\Adapter\Aggregation\Checker\Query;
namespace Niks\LayeredNavigation\Plugin;


use Magento\CatalogSearch\Model\Adapter\Aggregation\Checker\Query\CatalogView as CoreCatalogView;
use Magento\Framework\Search\RequestInterface;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Search\Request\QueryInterface;
use Magento\Framework\Search\Request\Query\BoolExpression;
use Magento\Framework\Exception\NoSuchEntityException;

class CatalogView extends CoreCatalogView
class CategoryAggregation
{
/**
* Identifier for query name
*/
private $name;

/**
* @var CategoryRepositoryInterface
*/
Expand All @@ -29,29 +24,26 @@ class CatalogView extends CoreCatalogView
/**
* @param CategoryRepositoryInterface $categoryRepository
* @param StoreManagerInterface $storeManager
* @param string $name
*/
public function __construct(
CategoryRepositoryInterface $categoryRepository,
StoreManagerInterface $storeManager,
$name
StoreManagerInterface $storeManager
) {
$this->categoryRepository = $categoryRepository;
$this->storeManager = $storeManager;
$this->name = $name;
}

/**
* {@inheritdoc}
*/
public function isApplicable(RequestInterface $request)
public function aroundIsApplicable(
\Magento\CatalogSearch\Model\Adapter\Aggregation\Checker\Query\CatalogView $subject,
\Closure $proceed,
RequestInterface $request
)
{
$result = true;
if ($request->getName() === $this->name) {
$result = $this->hasAnchorCategory($request);
if ($request->getName() === 'catalog_view_container') {
return $this->hasAnchorCategory($request);
}

return $result;
return $proceed($request);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"php": "~5.5.0|~5.6.0|~7.0.0"
},
"type": "magento2-module",
"version": "0.0.2",
"version": "0.0.3",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
8 changes: 2 additions & 6 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
<plugin name="multiple_category_ids" type="Niks\LayeredNavigation\Plugin\Preprocessor" sortOrder="1" />
</type>

<type name="Magento\CatalogSearch\Model\Adapter\Aggregation\RequestCheckerComposite">
<arguments>
<argument name="queryCheckers" xsi:type="array">
<item name="catalog_view_container" xsi:type="object">\Niks\LayeredNavigation\Model\Adapter\Aggregation\Checker\Query\CatalogView</item>
</argument>
</arguments>
<type name="Magento\CatalogSearch\Model\Adapter\Aggregation\Checker\Query\CatalogView">
<plugin name="category_aggregation" type="Niks\LayeredNavigation\Plugin\CategoryAggregation" sortOrder="1" />
</type>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Niks_LayeredNavigation" setup_version="0.0.1" >
<module name="Niks_LayeredNavigation" setup_version="0.0.3" >
<sequence>
<module name="Magento_CatalogSearch"/>
<module name="Magento_Swatches" />
Expand Down

0 comments on commit cfa78e9

Please sign in to comment.