From 5d80331afe2dd595e889e3607cb4b5a72207957a Mon Sep 17 00:00:00 2001 From: Pierre Gauthier Date: Wed, 4 Dec 2024 15:59:54 +0100 Subject: [PATCH] Add attribute in autocomplete --- src/Resources/config/services/search.yml | 8 +++ .../templates/search-autocomplete.html | 17 +++++ .../layouts/default/config/jsmodules.yml | 3 + src/Search/Autocomplete/Attribute.php | 68 +++++++++++++++++++ src/Search/SearchEngine.php | 7 +- src/Service/ContextProvider.php | 12 ++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 src/Search/Autocomplete/Attribute.php diff --git a/src/Resources/config/services/search.yml b/src/Resources/config/services/search.yml index 510dbe1..aebd378 100644 --- a/src/Resources/config/services/search.yml +++ b/src/Resources/config/services/search.yml @@ -94,3 +94,11 @@ services: - '@Gally\OroPlugin\Config\ConfigManager' tags: - { name: kernel.event_listener, event: Oro\Bundle\ProductBundle\Event\ProcessAutocompleteDataEvent, method: onProcessAutocompleteData } + + Gally\OroPlugin\Search\Autocomplete\Attribute: + arguments: + - '@Gally\OroPlugin\Service\ContextProvider' + - '@Gally\OroPlugin\Config\ConfigManager' + - '@router' + tags: + - { name: kernel.event_listener, event: Oro\Bundle\ProductBundle\Event\ProcessAutocompleteDataEvent, method: onProcessAutocompleteData } diff --git a/src/Resources/public/default/templates/search-autocomplete.html b/src/Resources/public/default/templates/search-autocomplete.html index 835d76f..bcd5c4f 100644 --- a/src/Resources/public/default/templates/search-autocomplete.html +++ b/src/Resources/public/default/templates/search-autocomplete.html @@ -62,6 +62,23 @@ <% }) %> + <%_.each(attributes, function(attribute) { %> +
  • + +
    + +
    +
    +
    + <%= attribute.field %> +
    +
    + <%= attribute.label %> +
    +
    +
    +
  • + <% }) %>