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();
$booleanFilterLabels = [];
foreach ($this->currentFilterValue as $currentFilter) {
$booleanFilterLabels[] = (string) $this->getAttributeModel()->getSource()->getOptionText((int) $currentFilter);
}
$filterLabel = implode(', ', $booleanFilterLabels);
$filter = $this->_createItem($filterLabel, $this->currentFilterValue);
$layerState->addFilter($filter);
}
return $this;
}