Skip to content

Commit

Permalink
Merge pull request #8 from mageho/patch-1
Browse files Browse the repository at this point in the history
Remove facets when all options are the same for each products.
  • Loading branch information
romainruaud authored Mar 5, 2019
2 parents 321c1bf + 982e6ae commit 643cd4d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Model/Layer/Filter/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,18 @@ protected function _getItemsData()
}
}
krsort($optionsFacetedData);

foreach ($optionsFacetedData as $value => $data) {
$sumCount += (int) $data['count'];
$items[$value] = [
'label' => $value,
'value' => $value,
'count' => $sumCount,
];

$minCount = !empty($optionsFacetedData) ? min(array_column($optionsFacetedData, 'count')) : 0;

if (!empty($this->currentFilterValue) || $minCount < $productCollection->getSize()) {
foreach ($optionsFacetedData as $value => $data) {
$sumCount += (int) $data['count'];
$items[$value] = [
'label' => $value,
'value' => $value,
'count' => $sumCount,
];
}
}

return $items;
Expand Down

0 comments on commit 643cd4d

Please sign in to comment.