diff --git a/modules/rest_facets/rest_facets.info.yml b/modules/rest_facets/rest_facets.info.yml index 6d53c5a..51181e1 100644 --- a/modules/rest_facets/rest_facets.info.yml +++ b/modules/rest_facets/rest_facets.info.yml @@ -5,6 +5,7 @@ core: 8.x package: Search dependencies: - facets:facets + - drupal:rest test_dependencies: - search_api:search_api - facets:facets diff --git a/src/Plugin/facets/facet_source/SearchApiFacetSource.php b/src/Plugin/facets/facet_source/SearchApiFacetSource.php index b4f8499..9e1255c 100644 --- a/src/Plugin/facets/facet_source/SearchApiFacetSource.php +++ b/src/Plugin/facets/facet_source/SearchApiFacetSource.php @@ -138,6 +138,23 @@ class SearchApiFacetSource extends FacetSourcePluginBase { $search_id = $this->getDisplay()->getPluginId(); $results = $this->searchApiQueryHelper->getResults($search_id); + if ($results === NULL) { + // @todo: FIGURE OUT WHY WE NEED THIS SHIT. + // It looks like the getPluginId is + // "views_rest:search_content__rest_export_1" and the derivative id is + // "views_page:search_content__rest_export_1". + // It looks like another plugin is creating the display. + $ar = $this->searchApiQueryHelper->getAllResults(); + $der_id = $this->getDisplay()->getDerivativeId(); + + foreach ($ar as $k => $res) { + if (strpos($k, $der_id) !== FALSE) { + $results = $res; + } + } + // END. + } + // Get the results from the cache. It is possible it still errored out. if ($results instanceof ResultSetInterface) { // Get our facet data.