Skip to content

Commit

Permalink
Merge pull request #505 from algolia/develop
Browse files Browse the repository at this point in the history
Release 1.6.1
  • Loading branch information
Jan Petr authored Jul 18, 2016
2 parents f7a45c2 + a5a4e5a commit 531d8b9
Show file tree
Hide file tree
Showing 29 changed files with 474 additions and 408 deletions.
2 changes: 1 addition & 1 deletion Algolia_Algoliasearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Algolia_Algoliasearch>
<active>true</active>
<codePool>community</codePool>
<version>1.6.0</version>
<version>1.6.1</version>
</Algolia_Algoliasearch>
</modules>
</config>
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
## Change Log

### 1.6.1

#### UPDATES
- JavaScript templates were split to separate files (#483)
- Locale CSV file was moved from `en_GB` to `en_US` directory (#481)
- Template loader can load more then only two blocks (#502)

#### FIXES
- Fixed bug when `top.search` block was not overriden in some themes (#500)
- Fixed bug with reindexing with empty synonyms lines (#480)
- Localized strings are properly escaped in JavaScript now (#488)
- Fixed occasional warnings in `getProductsRecords` method (#503)
- Fixed duplicite CSS class names (#484)
- Potential **BC break** - please review your design and CSS so it follows new classes


### 1.6.0

#### NEW FEATURES
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This extension replaces the default search of Magento with a typo-tolerant, fast

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

![Latest version](https://img.shields.io/badge/latest-1.6.0-green.svg)
![Latest version](https://img.shields.io/badge/latest-1.6.1-green.svg)
![Magento 1.6.2](https://img.shields.io/badge/magento-1.6.2-blue.svg)
![Magento 1.7.1](https://img.shields.io/badge/magento-1.7.1-blue.svg)
![Magento 1.8.1](https://img.shields.io/badge/magento-1.8.1-blue.svg)
Expand Down
2 changes: 1 addition & 1 deletion code/Helper/Algoliahelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()
$this->resetCredentialsFromConfig();

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

public function resetCredentialsFromConfig()
Expand Down
15 changes: 14 additions & 1 deletion code/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,16 @@ public function rebuildStoreCategoryIndexPage($storeId, $collectionDefault, $pag
}
}

protected function getProductsRecords($storeId, $collection, $potentiallyDeletedProductsIds = null)
protected function getProductsRecords($storeId, $collection, $potentiallyDeletedProductsIds = [])
{
$productsToIndex = [];
$productsToRemove = [];

// In $potentiallyDeletedProductsIds there might be IDs of deleted products which will not be in a collection
if (is_array($potentiallyDeletedProductsIds)) {
$potentiallyDeletedProductsIds = array_combine($potentiallyDeletedProductsIds, $potentiallyDeletedProductsIds);
} else {
$potentiallyDeletedProductsIds = [];
}

$this->logger->start('CREATE RECORDS '.$this->logger->getStoreName($storeId));
Expand Down Expand Up @@ -613,4 +615,15 @@ public function stopEmulation($info)
$appEmulation->stopEnvironmentEmulation($info);
$this->logger->stop('STOP EMULATION');
}

public function escapeJsTranslatedString(Mage_Core_Block_Template $template, $string, $useAddSlashes = false)
{
$translated = $template->__($string);

if ($useAddSlashes === true) {
return addslashes($translated);
}

return json_encode($translated);
}
}
8 changes: 8 additions & 0 deletions code/Helper/Entity/Producthelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ public function setSettings($storeId, $saveToTmpIndicesToo = false)

$synonyms = $this->config->getSynonyms($storeId);
foreach ($synonyms as $objectID => $synonym) {
if (!trim($synonym['synonyms'])) {
continue;
}

$synonymsToSet[] = [
'objectID' => $objectID,
'type' => 'synonym',
Expand All @@ -347,6 +351,10 @@ public function setSettings($storeId, $saveToTmpIndicesToo = false)

$onewaySynonyms = $this->config->getOnewaySynonyms($storeId);
foreach ($onewaySynonyms as $objectID => $onewaySynonym) {
if (!trim($onewaySynonym['input']) || !trim($onewaySynonym['synonyms'])) {
continue;
}

$synonymsToSet[] = [
'objectID' => $objectID,
'type' => 'oneWaySynonym',
Expand Down
2 changes: 1 addition & 1 deletion code/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Algolia_Algoliasearch>
<version>1.6.0</version>
<version>1.6.1</version>
</Algolia_Algoliasearch>
</modules>
<frontend>
Expand Down
2 changes: 1 addition & 1 deletion code/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<algoliasearch translate="label" module="algoliasearch">
<label>
<![CDATA[
Algolia Search 1.6.0
Algolia Search 1.6.1
<style>
.algoliasearch-admin-menu span {
padding-left: 38px !important;
Expand Down
26 changes: 20 additions & 6 deletions design/frontend/layout/algoliasearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,32 @@
</reference>
<reference name="before_body_end">
<block type="core/template" template="algoliasearch/internals/frontjs.phtml" name="algolia-beforebodyend"/>

<!-- Multi-category Autocomplete templates -->
<block type="core/template" template="algoliasearch/autocomplete/product.phtml" name="algolia-autocomplete-product"/>
<block type="core/template" template="algoliasearch/autocomplete/category.phtml" name="algolia-autocomplete-category"/>
<block type="core/template" template="algoliasearch/autocomplete/page.phtml" name="algolia-autocomplete-page"/>
<block type="core/template" template="algoliasearch/autocomplete/attribute.phtml" name="algolia-autocomplete-attribute"/>
<block type="core/template" template="algoliasearch/autocomplete/suggestion.phtml" name="algolia-autocomplete-suggestion"/>
<block type="core/template" template="algoliasearch/autocomplete/menu.phtml" name="algolia-autocomplete-menu"/>

<!-- Instant search results page templates -->
<block type="core/template" template="algoliasearch/instantsearch/wrapper.phtml" name="algolia-instantsearch-wrapper"/>
<block type="core/template" template="algoliasearch/instantsearch/hit.phtml" name="algolia-instantsearch-hit"/>
<block type="core/template" template="algoliasearch/instantsearch/stats.phtml" name="algolia-instantsearch-stats"/>
<block type="core/template" template="algoliasearch/instantsearch/facet.phtml" name="algolia-instantsearch-facet"/>
<block type="core/template" template="algoliasearch/instantsearch/refinements.phtml" name="algolia-instantsearch-refinements"/>
</reference>
<reference name="content">
<block type="core/template" before="content" template="algoliasearch/internals/beforecontent.phtml" name="algolia-beforecontent"/>
</reference>
</algolia_search_handle>
<algolia_search_handle_with_topsearch>
<reference name="header">
<block type="core/template" name="top.search" as="topSearch" template="algoliasearch/internals/templateloader.phtml">
<!-- Autocomplete.phtml must be loaded after Instantsearch.phtml to be able to bind to the recreated <div id="algolia-autocomplete-container"></div> -->
<block type="core/template" template="algoliasearch/instantsearch.phtml" as="algolia-instantsearch" name="algolia-instantsearch"/>
<block type="core/template" template="algoliasearch/autocomplete.phtml" as="algolia-autocomplete" name="algolia-autocomplete"/>
</block>
<reference name="top.search">
<action method="setTemplate"><template>algoliasearch/internals/templateloader.phtml</template></action>

<block type="core/template" template="algoliasearch/instantsearch.phtml" as="algolia-instantsearch" name="algolia-instantsearch"/>
<block type="core/template" template="algoliasearch/autocomplete.phtml" as="algolia-autocomplete" name="algolia-autocomplete"/>
</reference>
</algolia_search_handle_with_topsearch>
<algolia_search_handle_no_topsearch>
Expand Down
154 changes: 7 additions & 147 deletions design/frontend/template/autocomplete.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
/** @var Algolia_Algoliasearch_Helper_Config $config */
$config = Mage::helper('algoliasearch/config');

/** @var Algolia_Algoliasearch_Helper_Data $helper */
$helper = Mage::helper('algoliasearch');

/** @var Mage_CatalogSearch_Helper_Data $catalogSearchHelper */
$catalogSearchHelper = $this->helper('catalogsearch');

/** @var Mage_Customer_Model_Session $session */
$session = Mage::getSingleton('customer/session');
$group_id = $session->getCustomerGroupId();

$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
$price_key = $config->isCustomerGroupsEnabled(Mage::app()->getStore()->getStoreId()) ? '.'.$currency_code.'.group_'.$group_id : '.'.$currency_code.'.default';

$image_base_url = Mage::getBaseUrl();

$placeholder = $this->__('Search for products, categories, ...');

/** Render form with autocomplete input **/
Expand All @@ -35,140 +29,6 @@ if ($config->isDefaultSelector()): ?>
</form>
<?php endif; ?>

<!-- Product hit template -->
<script type="text/template" id="autocomplete_products_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
{{#thumbnail_url}}
<div class="thumb"><img src="<?php echo $image_base_url; ?>{{thumbnail_url}}" /></div>
{{/thumbnail_url}}

<div class="info">
{{{_highlightResult.name.value}}}

<div class="algoliasearch-autocomplete-category">
{{#categories_without_path}}
<?php echo $this->__('in'); ?> {{{categories_without_path}}}
{{/categories_without_path}}

{{#_highlightResult.color}}
{{#_highlightResult.color.value}}
<span>
{{#categories_without_path}} | {{/categories_without_path}} Color: {{{_highlightResult.color.value}}}
</span>
{{/_highlightResult.color.value}}
{{/_highlightResult.color}}
</div>

<div class="algoliasearch-autocomplete-price">
<span class="after_special {{#price<?php echo $price_key; ?>_original_formated}}promotion{{/price<?php echo $price_key; ?>_original_formated}}">
{{price<?php echo $price_key; ?>_formated}}
</span>

{{#price<?php echo $price_key; ?>_original_formated}}
<span class="before_special">
{{price<?php echo $price_key; ?>_original_formated}}
</span>
{{/price<?php echo $price_key; ?>_original_formated}}
</div>
</div>
</a>
</script>

<!-- Category hit template -->
<script type="text/template" id="autocomplete_categories_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
{{#image_url}}
<div class="thumb">
<img src="<?php echo $image_base_url; ?>{{image_url}}" />
</div>
{{/image_url}}

{{#image_url}}
<div class="info">
{{/image_url}}
{{^image_url}}
<div class="info-without-thumb">
{{#_highlightResult.path}}
{{{_highlightResult.path.value}}}
{{/_highlightResult.path}}
{{^_highlightResult.path}}
{{{path}}}
{{/_highlightResult.path}}

{{#product_count}}
<small>({{product_count}})</small>
{{/product_count}}

</div>
<div class="clearfix"></div>
{{/image_url}}
</div>
</a>
</script>

<!-- Page hit template -->
<script type="text/template" id="autocomplete_pages_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
<div class="info-without-thumb">
{{{_highlightResult.name.value}}}
{{#content}}
<div class="details">
{{{content}}}
</div>
{{/content}}
</div>
<div class="clearfix"></div>
</a>
</script>

<!-- Extra attribute hit template -->
<script type="text/template" id="autocomplete_extra_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
<div class="info-without-thumb">
{{{_highlightResult.value.value}}}
</div>
<div class="clearfix"></div>
</a>
</script>

<!-- Suggestion hit template -->
<script type="text/template" id="autocomplete_suggestions_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
<svg xmlns="http://www.w3.org/2000/svg" class="algolia-glass-suggestion magnifying-glass" width="24" height="24" viewBox="0 0 128 128" >
<g transform="scale(2.5)">
<path stroke-width="3" d="M19.5 19.582l9.438 9.438"></path>
<circle stroke-width="3" cx="12" cy="12" r="10.5" fill="none"></circle>
<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>
</g>
</svg>
<div class="info-without-thumb">
{{{_highlightResult.query.value}}}

{{#category}}
<span class="text-muted"><?php echo $this->__('in'); ?></span> <span class="category-tag">{{category}}</span>
{{/category}}
</div>
<div class="clearfix"></div>
</a>
</script>

<!-- General autocomplete menu template -->
<script type="text/template" id="menu-template">
<div class="autocomplete-wrapper">
<div class="col9">
<div class="aa-dataset-products"></div>
</div>
<div class="col3">
<div class="other-sections">
<div class="aa-dataset-suggestions"></div>
<?php for ($i = 0; $i < 10; $i++): ?>
<div class="aa-dataset-<?php echo $i; ?>"></div>
<?php endfor; ?>
</div>
</div>
</div>
</script>

<script type="text/javascript">
//<![CDATA[

Expand All @@ -194,7 +54,7 @@ if ($config->isDefaultSelector()): ?>
};

/**
* Initialise Algolia client
* Initialise Algolia client
* Docs: https://www.algolia.com/doc/javascript
**/
var algolia_client = algoliaBundle.algoliasearch(algoliaConfig.applicationId, algoliaConfig.apiKey);
Expand All @@ -209,8 +69,8 @@ if ($config->isDefaultSelector()): ?>
algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_que, label: '', name: "suggestions"});
}

algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: <?php echo json_encode($this->__('Categories')); ?>, name: "categories"});
algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: <?php echo json_encode($this->__('Products')); ?>, name: "products"});
algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: <?php echo $helper->escapeJsTranslatedString($this, 'Categories'); ?>, name: "categories"});
algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: <?php echo $helper->escapeJsTranslatedString($this, 'Products'); ?>, name: "products"});

/** Setup autocomplete data sources **/
var sources = [],
Expand Down Expand Up @@ -245,7 +105,7 @@ if ($config->isDefaultSelector()): ?>
};

if (algoliaConfig.removeBranding === false) {
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>';
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>';
}

/** Bind autocomplete feature to the input */
Expand Down
9 changes: 9 additions & 0 deletions design/frontend/template/autocomplete/attribute.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Extra attribute hit template -->
<script type="text/template" id="autocomplete_extra_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
<div class="info-without-thumb">
{{{_highlightResult.value.value}}}
</div>
<div class="clearfix"></div>
</a>
</script>
Loading

0 comments on commit 531d8b9

Please sign in to comment.