diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index b4c51edad5..faddcea344 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -221,7 +221,7 @@ class Query implements ControllerProviderInterface return $app->json([ 'current' => $app['twig']->render('prod/preview/result_train.html.twig', [ - 'records' => $record->get_train($pos, $query, $app['phraseanet.SE']), + 'records' => $record->get_train($pos, $query, $app['phraseanet.SE'], $options), 'selected' => $pos ]) ]); diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php index 39a49761ea..7bc6d2804c 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php @@ -497,6 +497,8 @@ class SearchEngineOptions $options = new static(); $options->disallowBusinessFields(); + $sort_by = $sort_ord = null; + foreach ($serialized as $key => $value) { switch (true) { @@ -530,8 +532,6 @@ class SearchEngineOptions break; } - $sort_by = $sort_ord = null; - switch ($key) { case 'record_type': $options->setRecordType($value); diff --git a/lib/classes/record/preview.php b/lib/classes/record/preview.php index 011f3542ff..9316a2034b 100644 --- a/lib/classes/record/preview.php +++ b/lib/classes/record/preview.php @@ -204,7 +204,7 @@ class record_preview extends record_adapter return $this; } - public function get_train($pos = 0, $query = '', SearchEngineInterface $search_engine = null) + public function get_train($pos = 0, $query = '', SearchEngineInterface $search_engine = null, SearchEngineOptions $options) { if ($this->train) { return $this->train; @@ -214,7 +214,7 @@ class record_preview extends record_adapter case 'RESULT': $perPage = 56; $index = ($pos - 3) < 0 ? 0 : ($pos - 3); - $results = $search_engine->query($query, $index, $perPage); + $results = $search_engine->query($query, $index, $perPage, $options); $this->train = $results->getResults()->toArray(); break;