public function apply(\Magento\Framework\App\RequestInterface $request)
{
$categoryId = $request->getParam($this->_requestVar) ?: $request->getParam('id');
if (!empty($categoryId)) {
$this->dataProvider->setCategoryId($categoryId);
$category = $this->dataProvider->getCategory();
$this->applyCategoryFilterToCollection($category);
if ($request->getParam('id') != $category->getId() && $this->dataProvider->isValid()) {
$this->getLayer()->getState()->addFilter($this->_createItem($category->getName(), $categoryId));
}
}
return $this;
}