public function apply(\Magento\Framework\App\RequestInterface $request)
{
/**
* Filter must be string: $fromPrice-$toPrice
*/
$filter = $request->getParam($this->getRequestVar());
if ($filter && !is_array($filter)) {
$filterParams = explode(',', $filter);
$filter = $this->dataProvider->validateFilter($filterParams[0]);
if ($filter) {
$this->dataProvider->setInterval($filter);
$priorFilters = $this->dataProvider->getPriorFilters($filterParams);
if ($priorFilters) {
$this->dataProvider->setPriorIntervals($priorFilters);
}
list($fromValue, $toValue) = $filter;
$this->setCurrentValue(['from' => $fromValue, 'to' => $toValue]);
$this->getLayer()->getProductCollection()->addFieldToFilter($this->getAttributeModel()->getAttributeCode(), ['from' => $fromValue, 'to' => $toValue]);
$this->getLayer()->getState()->addFilter($this->_createItem($this->_renderRangeLabel(empty($fromValue) ? 0 : $fromValue, $toValue), $filter));
}
}
return $this;
}