public function apply(\Magento\Framework\App\RequestInterface $request)
{
$attributeValue = $request->getParam($this->_requestVar);
if (!empty($attributeValue)) {
if (!is_array($attributeValue)) {
$attributeValue = [$attributeValue];
}
$this->currentFilterValue = $attributeValue;
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()->getProductCollection();
$productCollection->addFieldToFilter($this->getFilterField(), $attributeValue);
$layerState = $this->getLayer()->getState();
$filterLabel = implode(', ', $this->currentFilterValue);
$filter = $this->_createItem($filterLabel, $this->currentFilterValue);
$layerState->addFilter($filter);
}
return $this;
}