diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index c44822b5c..ed1e2d44b 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -81,9 +81,7 @@ public function listAction(): void $this->logger->error('Apache Solr not available'); return; } - // We only care about the UID and partOf in the results and want them sorted - $params['fields'] = 'uid,partof'; - $params['sort'] = ['uid' => 'asc']; + $collections = []; // Sort collections according to order in plugin flexform configuration @@ -220,22 +218,29 @@ private function processCollections($collections, Solr $solr): array // Process results. foreach ($collections as $collection) { - $solr_query = ''; + $solrQuery = ''; if ($collection->getIndexSearch() != '') { - $solr_query .= '(' . $collection->getIndexSearch() . ')'; + $solrQuery .= '(' . $collection->getIndexSearch() . ')'; } else { - $solr_query .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")'; + $solrQuery .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")'; } + // We only care about the UID and partOf in the results and want them sorted + $params = [ + 'fields' => 'uid,partof', + 'sort' => [ + 'uid' => 'asc' + ] + ]; // virtual collection might yield documents, that are not toplevel true or partof anything if ($collection->getIndexSearch()) { - $params['query'] = $solr_query; + $params['query'] = $solrQuery; } else { - $params['query'] = $solr_query . ' AND partof:0 AND toplevel:true'; + $params['query'] = $solrQuery . ' AND partof:0 AND toplevel:true'; } $partOfNothing = $solr->searchRaw($params); - $params['query'] = $solr_query . ' AND NOT partof:0 AND toplevel:true'; + $params['query'] = $solrQuery . ' AND NOT partof:0 AND toplevel:true'; $partOfSomething = $solr->searchRaw($params); $collectionInfo = [];