Browse Source

fix #600: only get distcinct results in search

Bachir Soussi Chiadmi 5 years ago
parent
commit
eb19a2f6b3

+ 7 - 1
web/modules/custom/edlp_search/src/Controller/EdlpSearchController.php

@@ -365,6 +365,7 @@ class EdlpSearchController extends ControllerBase {
     // dpm($items);
 
     $this->items = [];
+    $ids = [];
     foreach ($items as $item) {
       try {
         /** @var \Drupal\Core\Entity\EntityInterface $entity */
@@ -376,7 +377,12 @@ class EdlpSearchController extends ControllerBase {
       if (!$entity) {
         continue;
       }
-
+      // get distinct results
+      if(in_array($entity->id(), $ids)){
+        continue;
+      }
+      $ids[] = $entity->id();
+      // record results
       $this->items[] = $entity;
     }
     // dpm($this->items);