THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

Offline

#1 Intégration ALGOLIA

(19-02-2021 12:48:14)


Bonjour,
est ce que quelqu'un à déja intégré le moteur de recherche algolia sur son thelia ?

En tout cas je galère.

Offline

#2 Re: Intégration ALGOLIA

(19-02-2021 14:28:04)


Oui, moi ici : https://www.mondialcity.fr/
Que rencontres-tu comme difficulté(s) ?

Offline

#3 Re: Intégration ALGOLIA

(19-02-2021 17:41:48)


Merci pour ton exemple, au moins ça me montre que c'est possible !

J'ai réussi à construire un index avec du json.

Je n'arrive pas à faire en sorte d'avoir le moteur sur le site.
Est ce qu'il y a besoin d'un module ?

Ou juste en modifiant le hook-search et en ajoutant app.js dans src ça a une chance de fonctionner ?

Offline

#4 Re: Intégration ALGOLIA

(19-02-2021 17:58:20)


J'ai créer un module dédié.
Notamment pour indexer les produits dans Algolia.
Algolia dispose d'un SDK javascript qui permet d'intégrer relativement facilement le moteur de recherche sur un site me semble-t-il (https://www.algolia.com/doc/api-client/ … javascript)

Offline

#5 Re: Intégration ALGOLIA

(22-02-2021 11:15:22)


Ok j'ai fini par y arriver,

Sur desktop c ok, sur tablette et mobile, ça marche pas.
Je continue à gamberger à tout ça.

Je reviendrais poster comment j'ai fait,
ça pourra peut être servir.

Last edited by vz777 (22-02-2021 14:02:01)

Offline

#6 Re: Intégration ALGOLIA

(10-03-2021 12:42:52)


Ok si un jour quelqu'un veut mettre algolia en place,
il faut passer du rss (feed) au json.

Dans le dashboard algolia, il faut faire quelques réglages notamment attributes to snippet,
voir https://stackoverflow.com/questions/400 … arch-query

Pour ce qui est du code,
dans layout.tpl,
dans le head :

    {stylesheets file="assets/src/css/algolia.css"}
        <link href="{$asset_url}" rel="stylesheet" type="text/css" />
    {/stylesheets}

en bas, après l'appel à thelia.min

    <script  src="//cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
    <script src="//cdn.jsdelivr.net/autocomplete.js/0/autocomplete.min.js"></script>

    {javascripts file="assets/src/js/algo.js"}
     <script type="text/javascript" src="{$asset_url}"></script>
    {/javascripts}

il faut bien sur remplir YourApplicationID, YourSearchOnlyAPIKey, YourIndex avec ses propres données,
dans le fichier algolia.js :

<!-- Initialise search -->

var client = algoliasearch("YourApplicationID", "YourSearchOnlyAPIKey")
  var index = client.initIndex('YourIndex');
  var myAutocomplete = autocomplete('#q', {hint: false}, [
    {
      source: autocomplete.sources.hits(index, {hitsPerPage: 8}),
      displayKey: 'title',
      templates: {
        suggestion: function(suggestion) {
          var sugTemplate = "<div class=container><div class=col-md-12><img height=50 width=50 src='"+ suggestion.image +"'/>&nbsp;<span class=\'pull-right h5\'>"+ suggestion._highlightResult.title.value +"<\/span><\/div><\/div>"
          return sugTemplate;
        }
      }
    }
  ]).on('autocomplete:selected', function(event, suggestion, dataset) {
  window.location.href = suggestion.link;
});

Dans le fichier algolia.css

.aa-input-container {
  display: inline-block;
  position: relative;
}
.aa-input-search {
  width: 300px;
  padding: 12px 28px 12px 12px;
  border: 2px solid #e4e4e4;
  border-radius: 4px;
  -webkit-transition: .2s;
  transition: .2s;
  font-family: "Montserrat", sans-serif;
  box-shadow: 4px 4px 0 rgba(241, 241, 241, 0.35);
  font-size: 11px;
  box-sizing: border-box;
  color: #333;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.aa-input-search::-webkit-search-decoration, .aa-input-search::-webkit-search-cancel-button,
.aa-input-search::-webkit-search-results-button, .aa-input-search::-webkit-search-results-decoration {
  display: none;
}
.aa-input-search:focus {
  outline: 0;
  border-color: #3a96cf;
  box-shadow: 4px 4px 0 rgba(58, 150, 207, 0.1);
  }
.aa-input-icon {
  height: 16px;
  width: 16px;
  position: absolute;
  top: 50%;
  right: 16px;
  -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
  fill: #e4e4e4;
  pointer-events: none;
}
.aa-hint {
  color: #e4e4e4;
}
.aa-dropdown-menu {
  background-color: #fff;
  border: 2px solid rgba(228, 228, 228, 0.6);
  border-top-width: 0;
  font-family: "Montserrat", sans-serif;
  width: 300px;
  min-width:500px;
  margin-top: 10px;
  box-shadow: 4px 4px 0 rgba(241, 241, 241, 0.35);
  font-size: 11px;
  border-radius: 4px;
  box-sizing: border-box;
}
.aa-suggestion {
  padding: 6px 12px;
  cursor: pointer;
  -webkit-transition: .2s;
  transition: .2s;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}
.aa-suggestion:hover, .aa-suggestion.aa-cursor {
  background-color: rgba(241, 241, 241, 0.35);
}
.aa-suggestion > span:first-child {
    color: #333;
    }
.aa-suggestion > span:last-child {
    text-transform: uppercase;
    color: #a9a9a9;
}
.aa-suggestions-category {
  text-transform: uppercase;
  border-bottom: 2px solid rgba(228, 228, 228, 0.6);
  border-top: 2px solid rgba(228, 228, 228, 0.6);
  padding: 6px 12px;
  color: #a9a9a9;
}
.aa-suggestion > span:first-child em, .aa-suggestion > span:last-child em {
  font-weight: 700;
  font-style: normal;
  background-color: rgba(58, 150, 207, 0.1);
  padding: 2px 0 2px 2px;
}

Voila c'est peut être pas hyper propre, améliorable, n'hésitez pas à le dire, en tout cas chez moi ça fonctionne.
Si ça peut servir à quelqu'un, tant mieux.

Offline

#7 Re: Intégration ALGOLIA

(16-03-2021 18:53:31)


Merci !
Le sujet m'intéresse en effet.
As-tu essayé le module : "Product indexation and search with ElasticSearch" ? Je ne vais pas tarder à le tester pour voir comment il fonctionne : ça pourrait être une bonne alternative.

Al.


v. 1.5.4 - v 2.3.4 - v 2.4.3