Skip to content

Commit cfa51be

Browse files
committed
ACP2E-316: Some product are missed from layered navigation with manually configured price ranges
1 parent 9cab83d commit cfa51be

File tree

2 files changed

+9
-7
lines changed
  • app/code/Magento

2 files changed

+9
-7
lines changed

app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class Price extends AbstractFilter
1919
{
2020
/** Price delta for filter */
21-
public const PRICE_DELTA = 0.01;
21+
const PRICE_DELTA = 0.001;
2222

2323
/**
2424
* @var \Magento\Catalog\Model\Layer\Filter\DataProvider\Price
@@ -142,7 +142,7 @@ public function apply(\Magento\Framework\App\RequestInterface $request)
142142

143143
$this->getLayer()->getProductCollection()->addFieldToFilter(
144144
'price',
145-
['from' => $from, 'to' => $to]
145+
['from' => $from, 'to' => empty($to) || $from == $to ? $to : $to - self::PRICE_DELTA]
146146
);
147147

148148
$this->getLayer()->getState()->addFilter(
@@ -190,6 +190,10 @@ protected function _renderRangeLabel($fromPrice, $toPrice, $isLast = false)
190190
} elseif ($fromPrice == $toPrice && $this->dataProvider->getOnePriceIntervalValue()) {
191191
return $formattedFromPrice;
192192
} else {
193+
if ($fromPrice != $toPrice) {
194+
$toPrice -= .01;
195+
}
196+
193197
return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
194198
}
195199
}
@@ -270,9 +274,6 @@ protected function getFrom($from)
270274
private function prepareData($key, $count, $isLast = false)
271275
{
272276
[$from, $to] = explode('_', $key);
273-
if (!$isLast && !empty($to) && $to != $from) {
274-
$to -= self::PRICE_DELTA;
275-
}
276277
$label = $this->_renderRangeLabel($from, $to, $isLast);
277278
$value = $from . '-' . $to . $this->dataProvider->getAdditionalRequestData();
278279

app/code/Magento/Elasticsearch/SearchAdapter/Aggregation/Builder/Dynamic.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ private function prepareData(array $data, array $stats): array
8181
{
8282
$resultData = [];
8383
foreach ($data as $key => $value) {
84-
if (!isset($data[$key+1]) && isset($stats['max'])) {
85-
$value['to'] = $stats['max'];
84+
if (!isset($data[$key+1])) {
85+
$value['to'] = !isset($stats['max']) ? $value['to'] : $stats['max'];
86+
$value['to'] += 0.01;
8687
}
8788
$rangeName = "{$value['from']}_{$value['to']}";
8889
$value['value'] = $rangeName;

0 commit comments

Comments
 (0)