33/** @var Algolia_Algoliasearch_Helper_Config $config */
44$ config = Mage::helper ('algoliasearch/config ' );
55
6+ /** @var Algolia_Algoliasearch_Helper_Data $helper */
7+ $ helper = Mage::helper ('algoliasearch ' );
8+
69/** @var Mage_CatalogSearch_Helper_Data $catalogSearchHelper */
710$ catalogSearchHelper = $ this ->helper ('catalogsearch ' );
811
9- /** @var Mage_Customer_Model_Session $session */
10- $ session = Mage::getSingleton ('customer/session ' );
11- $ group_id = $ session ->getCustomerGroupId ();
12-
13- $ currency_code = Mage::app ()->getStore ()->getCurrentCurrencyCode ();
14- $ price_key = $ config ->isCustomerGroupsEnabled (Mage::app ()->getStore ()->getStoreId ()) ? '. ' .$ currency_code .'.group_ ' .$ group_id : '. ' .$ currency_code .'.default ' ;
15-
16- $ image_base_url = Mage::getBaseUrl ();
17-
1812$ placeholder = $ this ->__ ('Search for products, categories, ... ' );
1913
2014/** Render form with autocomplete input **/
@@ -35,140 +29,6 @@ if ($config->isDefaultSelector()): ?>
3529 </form>
3630<?php endif ; ?>
3731
38- <!-- Product hit template -->
39- <script type="text/template" id="autocomplete_products_template">
40- <a class="algoliasearch-autocomplete-hit" href="{{url}}">
41- {{#thumbnail_url}}
42- <div class="thumb"><img src="<?php echo $ image_base_url ; ?> {{thumbnail_url}}" /></div>
43- {{/thumbnail_url}}
44-
45- <div class="info">
46- {{{_highlightResult.name.value}}}
47-
48- <div class="algoliasearch-autocomplete-category">
49- {{#categories_without_path}}
50- <?php echo $ this ->__ ('in ' ); ?> {{{categories_without_path}}}
51- {{/categories_without_path}}
52-
53- {{#_highlightResult.color}}
54- {{#_highlightResult.color.value}}
55- <span>
56- {{#categories_without_path}} | {{/categories_without_path}} Color: {{{_highlightResult.color.value}}}
57- </span>
58- {{/_highlightResult.color.value}}
59- {{/_highlightResult.color}}
60- </div>
61-
62- <div class="algoliasearch-autocomplete-price">
63- <span class="after_special {{#price<?php echo $ price_key ; ?> _original_formated}}promotion{{/price<?php echo $ price_key ; ?> _original_formated}}">
64- {{price<?php echo $ price_key ; ?> _formated}}
65- </span>
66-
67- {{#price<?php echo $ price_key ; ?> _original_formated}}
68- <span class="before_special">
69- {{price<?php echo $ price_key ; ?> _original_formated}}
70- </span>
71- {{/price<?php echo $ price_key ; ?> _original_formated}}
72- </div>
73- </div>
74- </a>
75- </script>
76-
77- <!-- Category hit template -->
78- <script type="text/template" id="autocomplete_categories_template">
79- <a class="algoliasearch-autocomplete-hit" href="{{url}}">
80- {{#image_url}}
81- <div class="thumb">
82- <img src="<?php echo $ image_base_url ; ?> {{image_url}}" />
83- </div>
84- {{/image_url}}
85-
86- {{#image_url}}
87- <div class="info">
88- {{/image_url}}
89- {{^image_url}}
90- <div class="info-without-thumb">
91- {{#_highlightResult.path}}
92- {{{_highlightResult.path.value}}}
93- {{/_highlightResult.path}}
94- {{^_highlightResult.path}}
95- {{{path}}}
96- {{/_highlightResult.path}}
97-
98- {{#product_count}}
99- <small>({{product_count}})</small>
100- {{/product_count}}
101-
102- </div>
103- <div class="clearfix"></div>
104- {{/image_url}}
105- </div>
106- </a>
107- </script>
108-
109- <!-- Page hit template -->
110- <script type="text/template" id="autocomplete_pages_template">
111- <a class="algoliasearch-autocomplete-hit" href="{{url}}">
112- <div class="info-without-thumb">
113- {{{_highlightResult.name.value}}}
114- {{#content}}
115- <div class="details">
116- {{{content}}}
117- </div>
118- {{/content}}
119- </div>
120- <div class="clearfix"></div>
121- </a>
122- </script>
123-
124- <!-- Extra attribute hit template -->
125- <script type="text/template" id="autocomplete_extra_template">
126- <a class="algoliasearch-autocomplete-hit" href="{{url}}">
127- <div class="info-without-thumb">
128- {{{_highlightResult.value.value}}}
129- </div>
130- <div class="clearfix"></div>
131- </a>
132- </script>
133-
134- <!-- Suggestion hit template -->
135- <script type="text/template" id="autocomplete_suggestions_template">
136- <a class="algoliasearch-autocomplete-hit" href="{{url}}">
137- <svg xmlns="http://www.w3.org/2000/svg" class="algolia-glass-suggestion magnifying-glass" width="24" height="24" viewBox="0 0 128 128" >
138- <g transform="scale(2.5)">
139- <path stroke-width="3" d="M19.5 19.582l9.438 9.438"></path>
140- <circle stroke-width="3" cx="12" cy="12" r="10.5" fill="none"></circle>
141- <path d="M23.646 20.354l-3.293 3.293c-.195.195-.195.512 0 .707l7.293 7.293c.195.195.512.195.707 0l3.293-3.293c.195-.195.195-.512 0-.707l-7.293-7.293c-.195-.195-.512-.195-.707 0z" ></path>
142- </g>
143- </svg>
144- <div class="info-without-thumb">
145- {{{_highlightResult.query.value}}}
146-
147- {{#category}}
148- <span class="text-muted"><?php echo $ this ->__ ('in ' ); ?> </span> <span class="category-tag">{{category}}</span>
149- {{/category}}
150- </div>
151- <div class="clearfix"></div>
152- </a>
153- </script>
154-
155- <!-- General autocomplete menu template -->
156- <script type="text/template" id="menu-template">
157- <div class="autocomplete-wrapper">
158- <div class="col9">
159- <div class="aa-dataset-products"></div>
160- </div>
161- <div class="col3">
162- <div class="other-sections">
163- <div class="aa-dataset-suggestions"></div>
164- <?php for ($ i = 0 ; $ i < 10 ; $ i ++): ?>
165- <div class="aa-dataset-<?php echo $ i ; ?> "></div>
166- <?php endfor ; ?>
167- </div>
168- </div>
169- </div>
170- </script>
171-
17232<script type="text/javascript">
17333 //<![CDATA[
17434
@@ -194,7 +54,7 @@ if ($config->isDefaultSelector()): ?>
19454 };
19555
19656 /**
197- * Initialise Algolia client
57+ * Initialise Algolia client
19858 * Docs: https://www.algolia.com/doc/javascript
19959 **/
20060 var algolia_client = algoliaBundle.algoliasearch(algoliaConfig.applicationId, algoliaConfig.apiKey);
@@ -209,8 +69,8 @@ if ($config->isDefaultSelector()): ?>
20969 algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_que, label: '', name: "suggestions"});
21070 }
21171
212- algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: <?php echo json_encode ( $ this -> __ ( 'Categories ' ) ); ?> , name: "categories"});
213- algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: <?php echo json_encode ( $ this -> __ ( 'Products ' ) ); ?> , name: "products"});
72+ algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: <?php echo $ helper -> escapeJsTranslatedString ( $ this , 'Categories ' ); ?> , name: "categories"});
73+ algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: <?php echo $ helper -> escapeJsTranslatedString ( $ this , 'Products ' ); ?> , name: "products"});
21474
21575 /** Setup autocomplete data sources **/
21676 var sources = [],
@@ -245,7 +105,7 @@ if ($config->isDefaultSelector()): ?>
245105 };
246106
247107 if (algoliaConfig.removeBranding === false) {
248- options.templates.footer = '<div class="footer_algolia"><span><?php echo $ this -> __ ( 'Search by ' ); ?> </span> <a href="https://www.algolia.com/?utm_source=magento&utm_medium=link&utm_campaign=magento_autocompletion_menu" target="_blank"><img src="<?php echo $ this ->getSkinUrl ('algoliasearch/algolia-logo.png ' ); ?> " /></a></div>';
108+ options.templates.footer = '<div class="footer_algolia"><span><?php echo $ helper -> escapeJsTranslatedString ( $ this , 'Search by ' , true ); ?> </span> <a href="https://www.algolia.com/?utm_source=magento&utm_medium=link&utm_campaign=magento_autocompletion_menu" target="_blank"><img src="<?php echo $ this ->getSkinUrl ('algoliasearch/algolia-logo.png ' ); ?> " /></a></div>';
249109 }
250110
251111 /** Bind autocomplete feature to the input */
0 commit comments