Skip to content

Commit

Permalink
Remove facets when all options are the same for each products.
Browse files Browse the repository at this point in the history
Related to this core issue : 
Smile-SA/elasticsuite#1051

I have just applied what @afoucret done.

Tell me if it is ok for you.

Ilan PARMENTIER
  • Loading branch information
Ilan Parmentier authored Oct 3, 2018
1 parent 321c1bf commit 982e6ae
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 982e6ae

Please sign in to comment.