Skip to content

Commit 531d8b9

Browse files
author
Jan Petr
authored
Merge pull request #505 from algolia/develop
Release 1.6.1
2 parents f7a45c2 + a5a4e5a commit 531d8b9

29 files changed

+474
-408
lines changed

Algolia_Algoliasearch.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Algolia_Algoliasearch>
55
<active>true</active>
66
<codePool>community</codePool>
7-
<version>1.6.0</version>
7+
<version>1.6.1</version>
88
</Algolia_Algoliasearch>
99
</modules>
1010
</config>

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
## Change Log
22

3+
### 1.6.1
4+
5+
#### UPDATES
6+
- JavaScript templates were split to separate files (#483)
7+
- Locale CSV file was moved from `en_GB` to `en_US` directory (#481)
8+
- Template loader can load more then only two blocks (#502)
9+
10+
#### FIXES
11+
- Fixed bug when `top.search` block was not overriden in some themes (#500)
12+
- Fixed bug with reindexing with empty synonyms lines (#480)
13+
- Localized strings are properly escaped in JavaScript now (#488)
14+
- Fixed occasional warnings in `getProductsRecords` method (#503)
15+
- Fixed duplicite CSS class names (#484)
16+
- Potential **BC break** - please review your design and CSS so it follows new classes
17+
18+
319
### 1.6.0
420

521
#### NEW FEATURES

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This extension replaces the default search of Magento with a typo-tolerant, fast
77

88
See features and benefits of [Algolia Search Extension for Magento](https://community.algolia.com/magento).
99

10-
![Latest version](https://img.shields.io/badge/latest-1.6.0-green.svg)
10+
![Latest version](https://img.shields.io/badge/latest-1.6.1-green.svg)
1111
![Magento 1.6.2](https://img.shields.io/badge/magento-1.6.2-blue.svg)
1212
![Magento 1.7.1](https://img.shields.io/badge/magento-1.7.1-blue.svg)
1313
![Magento 1.8.1](https://img.shields.io/badge/magento-1.8.1-blue.svg)

code/Helper/Algoliahelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct()
1818
$this->resetCredentialsFromConfig();
1919

2020
$version = $this->config->getExtensionVersion();
21-
\AlgoliaSearch\Version::$custom_value = ' Magento ('.$version.')';
21+
\AlgoliaSearch\Version::$custom_value = '; Magento integration '.$version.'; PHP '.phpversion().'; Magento '.Mage::getVersion();
2222
}
2323

2424
public function resetCredentialsFromConfig()

code/Helper/Data.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,16 @@ public function rebuildStoreCategoryIndexPage($storeId, $collectionDefault, $pag
430430
}
431431
}
432432

433-
protected function getProductsRecords($storeId, $collection, $potentiallyDeletedProductsIds = null)
433+
protected function getProductsRecords($storeId, $collection, $potentiallyDeletedProductsIds = [])
434434
{
435435
$productsToIndex = [];
436436
$productsToRemove = [];
437437

438438
// In $potentiallyDeletedProductsIds there might be IDs of deleted products which will not be in a collection
439439
if (is_array($potentiallyDeletedProductsIds)) {
440440
$potentiallyDeletedProductsIds = array_combine($potentiallyDeletedProductsIds, $potentiallyDeletedProductsIds);
441+
} else {
442+
$potentiallyDeletedProductsIds = [];
441443
}
442444

443445
$this->logger->start('CREATE RECORDS '.$this->logger->getStoreName($storeId));
@@ -613,4 +615,15 @@ public function stopEmulation($info)
613615
$appEmulation->stopEnvironmentEmulation($info);
614616
$this->logger->stop('STOP EMULATION');
615617
}
618+
619+
public function escapeJsTranslatedString(Mage_Core_Block_Template $template, $string, $useAddSlashes = false)
620+
{
621+
$translated = $template->__($string);
622+
623+
if ($useAddSlashes === true) {
624+
return addslashes($translated);
625+
}
626+
627+
return json_encode($translated);
628+
}
616629
}

code/Helper/Entity/Producthelper.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ public function setSettings($storeId, $saveToTmpIndicesToo = false)
338338

339339
$synonyms = $this->config->getSynonyms($storeId);
340340
foreach ($synonyms as $objectID => $synonym) {
341+
if (!trim($synonym['synonyms'])) {
342+
continue;
343+
}
344+
341345
$synonymsToSet[] = [
342346
'objectID' => $objectID,
343347
'type' => 'synonym',
@@ -347,6 +351,10 @@ public function setSettings($storeId, $saveToTmpIndicesToo = false)
347351

348352
$onewaySynonyms = $this->config->getOnewaySynonyms($storeId);
349353
foreach ($onewaySynonyms as $objectID => $onewaySynonym) {
354+
if (!trim($onewaySynonym['input']) || !trim($onewaySynonym['synonyms'])) {
355+
continue;
356+
}
357+
350358
$synonymsToSet[] = [
351359
'objectID' => $objectID,
352360
'type' => 'oneWaySynonym',

code/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<config>
33
<modules>
44
<Algolia_Algoliasearch>
5-
<version>1.6.0</version>
5+
<version>1.6.1</version>
66
</Algolia_Algoliasearch>
77
</modules>
88
<frontend>

code/etc/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<algoliasearch translate="label" module="algoliasearch">
55
<label>
66
<![CDATA[
7-
Algolia Search 1.6.0
7+
Algolia Search 1.6.1
88
<style>
99
.algoliasearch-admin-menu span {
1010
padding-left: 38px !important;

design/frontend/layout/algoliasearch.xml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,32 @@
1717
</reference>
1818
<reference name="before_body_end">
1919
<block type="core/template" template="algoliasearch/internals/frontjs.phtml" name="algolia-beforebodyend"/>
20+
21+
<!-- Multi-category Autocomplete templates -->
22+
<block type="core/template" template="algoliasearch/autocomplete/product.phtml" name="algolia-autocomplete-product"/>
23+
<block type="core/template" template="algoliasearch/autocomplete/category.phtml" name="algolia-autocomplete-category"/>
24+
<block type="core/template" template="algoliasearch/autocomplete/page.phtml" name="algolia-autocomplete-page"/>
25+
<block type="core/template" template="algoliasearch/autocomplete/attribute.phtml" name="algolia-autocomplete-attribute"/>
26+
<block type="core/template" template="algoliasearch/autocomplete/suggestion.phtml" name="algolia-autocomplete-suggestion"/>
27+
<block type="core/template" template="algoliasearch/autocomplete/menu.phtml" name="algolia-autocomplete-menu"/>
28+
29+
<!-- Instant search results page templates -->
30+
<block type="core/template" template="algoliasearch/instantsearch/wrapper.phtml" name="algolia-instantsearch-wrapper"/>
31+
<block type="core/template" template="algoliasearch/instantsearch/hit.phtml" name="algolia-instantsearch-hit"/>
32+
<block type="core/template" template="algoliasearch/instantsearch/stats.phtml" name="algolia-instantsearch-stats"/>
33+
<block type="core/template" template="algoliasearch/instantsearch/facet.phtml" name="algolia-instantsearch-facet"/>
34+
<block type="core/template" template="algoliasearch/instantsearch/refinements.phtml" name="algolia-instantsearch-refinements"/>
2035
</reference>
2136
<reference name="content">
2237
<block type="core/template" before="content" template="algoliasearch/internals/beforecontent.phtml" name="algolia-beforecontent"/>
2338
</reference>
2439
</algolia_search_handle>
2540
<algolia_search_handle_with_topsearch>
26-
<reference name="header">
27-
<block type="core/template" name="top.search" as="topSearch" template="algoliasearch/internals/templateloader.phtml">
28-
<!-- Autocomplete.phtml must be loaded after Instantsearch.phtml to be able to bind to the recreated <div id="algolia-autocomplete-container"></div> -->
29-
<block type="core/template" template="algoliasearch/instantsearch.phtml" as="algolia-instantsearch" name="algolia-instantsearch"/>
30-
<block type="core/template" template="algoliasearch/autocomplete.phtml" as="algolia-autocomplete" name="algolia-autocomplete"/>
31-
</block>
41+
<reference name="top.search">
42+
<action method="setTemplate"><template>algoliasearch/internals/templateloader.phtml</template></action>
43+
44+
<block type="core/template" template="algoliasearch/instantsearch.phtml" as="algolia-instantsearch" name="algolia-instantsearch"/>
45+
<block type="core/template" template="algoliasearch/autocomplete.phtml" as="algolia-autocomplete" name="algolia-autocomplete"/>
3246
</reference>
3347
</algolia_search_handle_with_topsearch>
3448
<algolia_search_handle_no_topsearch>

design/frontend/template/autocomplete.phtml

Lines changed: 7 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
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

Comments
 (0)