Commit 1803699a authored by git's avatar git Committed by StryKaizer

Issue #3018847 by uros.ceh: Facets summary always says 1 result found

parent 9db39454
......@@ -5,6 +5,8 @@
* Hook implementations for the facets summary module.
*/
use Drupal\search_api\Query\QueryInterface;
/**
* Implements hook_theme().
*/
......@@ -58,6 +60,25 @@ function facets_summary_theme($existing, $type, $theme, $path) {
];
}
/**
* Implements hook_search_api_query_alter().
*/
function facets_summary_search_api_query_alter(QueryInterface &$query) {
$facet_source_id = 'search_api:' . str_replace(':', '__', $query->getSearchId());
$storage = \Drupal::entityTypeManager()->getStorage('facets_summary');
// Get all the facet summaries for the facet source.
$facet_summaries = $storage->loadByProperties(['facet_source_id' => $facet_source_id]);
/** @var \Drupal\facets_summary\FacetsSummaryInterface $facet_summary */
foreach ($facet_summaries as $facet_summary) {
$processors = $facet_summary->getProcessors();
// If the count processor is enabled, results count must not be skipped.
if (in_array('show_count', array_keys($processors))) {
$query->setOption('skip result count', FALSE);
break;
}
}
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment