Skip to content

Commit

Permalink
Merge pull request #115 from tatiana-scandi/bugfix/3157/fix-price-layers
Browse files Browse the repository at this point in the history
#3157 - fix price ranges calculation
  • Loading branch information
carinadues authored Sep 22, 2021
2 parents f228963 + 77d91ae commit d6ac1c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Model/Layer/Filter/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function build(AggregationInterface $aggregation, ?int $storeId): array
// Builds graph-ql response
$result['options'][] = $this->layerFormatter->buildItem(
$priceRange['from'] . '~' . $priceRange['to'],
$priceRange['from'] . '_' . $priceRange['to'],
$metrics['value'],
$metrics['count']
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Resolver/Aggregations.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ protected function processPriceFilter(array $result): array {

foreach ($item['options'] as $index => $option) {
if ($lastIdx != 0 && $index == $lastIdx) {
$item['options'][$index]['label'] = preg_replace('/(\d+)~\d+/', '$1~*', $option['label']);
$item['options'][$index]['value'] = preg_replace('/(\d+)_\d+/', '$1_*', $option['value']);
$item['options'][$index]['label'] = preg_replace('/(\d+\.?\d*)~(\d+\.?\d*)/', '$1~*', $option['label']);
$item['options'][$index]['value'] = preg_replace('/(\d+\.?\d*)_(\d+\.?\d*)/', '$1_*', $option['value']);
} else {
$item['options'][$index]['label'] = preg_replace_callback('/(\d+~)(\d+)/', function ($matches) {
$item['options'][$index]['label'] = preg_replace_callback('/(\d+\.?\d*~)(\d+\.?\d*)/', function ($matches) {
return $matches[1].($matches[2]-0.01);
}, $option['label']);
$item['options'][$index]['value'] = preg_replace_callback('/(\d+_)(\d+)/', function ($matches) {
$item['options'][$index]['value'] = preg_replace_callback('/(\d+\.?\d*_)(\d+\.?\d*)/', function ($matches) {
return $matches[1].($matches[2]-0.01);
}, $option['value']);
}
Expand Down

0 comments on commit d6ac1c1

Please sign in to comment.