I am implementing multiple category filters for layered navigation. I am getting the result as per my requirement but the collection size is coming wrong remains same as the parent categories collection size.
Is there any other way to implement this functionality.
I have modified the following code :
public function apply(\Magento\Framework\App\RequestInterface $request)
{
$categoryId = $request->getParam($this->_requestVar) ?: $request->getParam('id');
if (empty($categoryId)) {
return $this;
}
$this->dataProvider->setCategoryId($categoryId);
$category = $this->dataProvider->getCategory();
**$this->getLayer()->getProductCollection()->addCategoryFilter($category);**
if ($request->getParam('id') != $category->getId() && $this->dataProvider->isValid()) {
$this->getLayer()->getState()->addFilter($this->_createItem($category->getName(), $categoryId));
}
return $this;
}
replaced the addCategoryFilter($category)
with addCategoriesFilter('eq' => $categoriesArray);
But as the layered navigation count is coming from somewhere else and not from product collection.
would like to know from where. And how could I apply multiple category filters there?