From ff38325a95566ad0f9187c4f6473331338681075 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Tue, 5 Jul 2016 17:03:42 +0200 Subject: [PATCH 01/25] Fix synonyms when there are only spaces --- code/Helper/Entity/Producthelper.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/Helper/Entity/Producthelper.php b/code/Helper/Entity/Producthelper.php index 2cca9a1b..9c25fa10 100644 --- a/code/Helper/Entity/Producthelper.php +++ b/code/Helper/Entity/Producthelper.php @@ -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', @@ -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', From 69f35c3c6d27bbeae029dfea50007beaec025341 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Wed, 6 Jul 2016 15:06:01 +0200 Subject: [PATCH 02/25] Move locale CSV file to en_US directory and change default language of container Magento to en_US --- dev/Dockerfile | 2 +- dev/bin/algoliasearch.xml | 2 +- locale/{en_GB => en_US}/Algolia_Algoliasearch.csv | 0 modman | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename locale/{en_GB => en_US}/Algolia_Algoliasearch.csv (100%) diff --git a/dev/Dockerfile b/dev/Dockerfile index a7b3e05d..9637f9b4 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -42,7 +42,7 @@ RUN chown -R www-data:www-data /var/www/htdocs ## database setup RUN service mysql start && (echo "CREATE DATABASE magento" | mysql -u root --password=P4ssw0rd) && mysql -u root --password=P4ssw0rd magento < /tmp/magento-sample-data-1.9.0.0/magento_sample_data_for_1.9.0.0.sql && service mysql stop -RUN service mysql start && MYSQL_HOST=127.0.0.1 MYSQL_USER=root MYSQL_PASSWORD=P4ssw0rd MYSQL_DATABASE=magento MAGENTO_LOCALE=en_GB MAGENTO_TIMEZONE=Europe/Paris MAGENTO_DEFAULT_CURRENCY=USD MAGENTO_URL=http://mymagentostore.com MAGENTO_ADMIN_FIRSTNAME=Admin MAGENTO_ADMIN_LASTNAME=MyStore MAGENTO_ADMIN_EMAIL=amdin@mymagentostore.com MAGENTO_ADMIN_USERNAME=admin MAGENTO_ADMIN_PASSWORD=magentorocks1 /usr/local/bin/install-magento && service mysql stop +RUN service mysql start && MYSQL_HOST=127.0.0.1 MYSQL_USER=root MYSQL_PASSWORD=P4ssw0rd MYSQL_DATABASE=magento MAGENTO_LOCALE=en_US MAGENTO_TIMEZONE=Europe/Paris MAGENTO_DEFAULT_CURRENCY=USD MAGENTO_URL=http://mymagentostore.com MAGENTO_ADMIN_FIRSTNAME=Admin MAGENTO_ADMIN_LASTNAME=MyStore MAGENTO_ADMIN_EMAIL=amdin@mymagentostore.com MAGENTO_ADMIN_USERNAME=admin MAGENTO_ADMIN_PASSWORD=magentorocks1 /usr/local/bin/install-magento && service mysql stop ## disable cache RUN service mysql start && n98-magerun --root-dir=/var/www/htdocs cache:flush && n98-magerun --root-dir=/var/www/htdocs cache:disable && service mysql stop diff --git a/dev/bin/algoliasearch.xml b/dev/bin/algoliasearch.xml index 775a9b2e..191f0783 100755 --- a/dev/bin/algoliasearch.xml +++ b/dev/bin/algoliasearch.xml @@ -90,7 +90,7 @@ lib/AlgoliaSearch adminhtml/default/default/template/algoliasearch adminhtml/default/default/layout/algoliasearch.xml - en_GB/Algolia_Algoliasearch.csv + en_US/Algolia_Algoliasearch.csv file diff --git a/locale/en_GB/Algolia_Algoliasearch.csv b/locale/en_US/Algolia_Algoliasearch.csv similarity index 100% rename from locale/en_GB/Algolia_Algoliasearch.csv rename to locale/en_US/Algolia_Algoliasearch.csv diff --git a/modman b/modman index 6ddd7061..02a1df8d 100644 --- a/modman +++ b/modman @@ -10,7 +10,7 @@ design/frontend/layout/algoliasearch.xml app/design/frontend/base/default/lay design/frontend/template app/design/frontend/base/default/template/algoliasearch design/adminhtml/layout/algoliasearch.xml app/design/adminhtml/default/default/layout/algoliasearch.xml design/adminhtml/template app/design/adminhtml/default/default/template/algoliasearch -locale/en_GB/Algolia_Algoliasearch.csv app/locale/en_GB/Algolia_Algoliasearch.csv +locale/en_US/Algolia_Algoliasearch.csv app/locale/en_US/Algolia_Algoliasearch.csv skin skin/frontend/base/default/algoliasearch js js/algoliasearch lib/AlgoliaSearch lib/AlgoliaSearch/ \ No newline at end of file From a2b6c192635d77b49fcb1d42eebb7c7408f018b6 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Thu, 7 Jul 2016 16:41:40 +0200 Subject: [PATCH 03/25] Separate autocomplete and instantsearch templates --- design/frontend/layout/algoliasearch.xml | 32 +++ design/frontend/template/autocomplete.phtml | 143 ----------- .../template/autocomplete/attribute.phtml | 9 + .../template/autocomplete/category.phtml | 37 +++ .../frontend/template/autocomplete/menu.phtml | 16 ++ .../frontend/template/autocomplete/page.phtml | 14 + .../template/autocomplete/product.phtml | 54 ++++ .../template/autocomplete/suggestion.phtml | 20 ++ design/frontend/template/instantsearch.phtml | 239 ------------------ .../template/instantsearch/facet.phtml | 8 + .../frontend/template/instantsearch/hit.phtml | 76 ++++++ .../template/instantsearch/refinements.phtml | 16 ++ .../template/instantsearch/stats.phtml | 6 + .../template/instantsearch/wrapper.phtml | 132 ++++++++++ 14 files changed, 420 insertions(+), 382 deletions(-) create mode 100644 design/frontend/template/autocomplete/attribute.phtml create mode 100644 design/frontend/template/autocomplete/category.phtml create mode 100644 design/frontend/template/autocomplete/menu.phtml create mode 100644 design/frontend/template/autocomplete/page.phtml create mode 100644 design/frontend/template/autocomplete/product.phtml create mode 100644 design/frontend/template/autocomplete/suggestion.phtml create mode 100644 design/frontend/template/instantsearch/facet.phtml create mode 100644 design/frontend/template/instantsearch/hit.phtml create mode 100644 design/frontend/template/instantsearch/refinements.phtml create mode 100644 design/frontend/template/instantsearch/stats.phtml create mode 100644 design/frontend/template/instantsearch/wrapper.phtml diff --git a/design/frontend/layout/algoliasearch.xml b/design/frontend/layout/algoliasearch.xml index 429be7f7..604136e7 100644 --- a/design/frontend/layout/algoliasearch.xml +++ b/design/frontend/layout/algoliasearch.xml @@ -30,6 +30,22 @@ + + + + + + + + + + + + + + + + @@ -37,5 +53,21 @@ + + + + + + + + + + + + + + + + diff --git a/design/frontend/template/autocomplete.phtml b/design/frontend/template/autocomplete.phtml index 5d728bf9..d258890e 100644 --- a/design/frontend/template/autocomplete.phtml +++ b/design/frontend/template/autocomplete.phtml @@ -6,15 +6,6 @@ $config = Mage::helper('algoliasearch/config'); /** @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 **/ @@ -35,140 +26,6 @@ if ($config->isDefaultSelector()): ?> - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/design/frontend/template/autocomplete/category.phtml b/design/frontend/template/autocomplete/category.phtml new file mode 100644 index 00000000..b4787ecb --- /dev/null +++ b/design/frontend/template/autocomplete/category.phtml @@ -0,0 +1,37 @@ + + + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/menu.phtml b/design/frontend/template/autocomplete/menu.phtml new file mode 100644 index 00000000..cc3bf19b --- /dev/null +++ b/design/frontend/template/autocomplete/menu.phtml @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/page.phtml b/design/frontend/template/autocomplete/page.phtml new file mode 100644 index 00000000..71d6a471 --- /dev/null +++ b/design/frontend/template/autocomplete/page.phtml @@ -0,0 +1,14 @@ + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/product.phtml b/design/frontend/template/autocomplete/product.phtml new file mode 100644 index 00000000..50b34629 --- /dev/null +++ b/design/frontend/template/autocomplete/product.phtml @@ -0,0 +1,54 @@ +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(); + +?> + + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/suggestion.phtml b/design/frontend/template/autocomplete/suggestion.phtml new file mode 100644 index 00000000..f46d930a --- /dev/null +++ b/design/frontend/template/autocomplete/suggestion.phtml @@ -0,0 +1,20 @@ + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch.phtml b/design/frontend/template/instantsearch.phtml index 63d837a2..5fe9457b 100644 --- a/design/frontend/template/instantsearch.phtml +++ b/design/frontend/template/instantsearch.phtml @@ -1,242 +1,3 @@ -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(); - -$title = ''; -$description = ''; -$content = ''; -$imgHtml = ''; - -if ($config->isInstantEnabled() && $config->replaceCategories() && Mage::app()->getRequest()->getControllerName() == 'category') { - $category = Mage::registry('current_category'); - $title = $category->getName(); - - if ($category && $category->getDisplayMode() !== 'PAGE') { - $category->getUrlInstance()->setStore(Mage::app()->getStore()->getStoreId()); - - if ($category->getDisplayMode() == 'PRODUCTS_AND_PAGE') { - $page = $category->getLandingPage(); - $cms_block = Mage::getModel('cms/block')->load($page); - - $description = $category->getDescription(); - $content = $this->getLayout()->createBlock('cms/block')->setBlockId($page)->toHtml(); - - if ($category->getImageUrl()) { - $imgHtml = '

'.$this->escapeHtml($category->getName()).'

'; - $imgHtml = $this->helper('catalog/output')->categoryAttribute($category, $imgHtml, 'image'); - } - } - } -} - -?> - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/design/frontend/template/instantsearch/hit.phtml b/design/frontend/template/instantsearch/hit.phtml new file mode 100644 index 00000000..e204386e --- /dev/null +++ b/design/frontend/template/instantsearch/hit.phtml @@ -0,0 +1,76 @@ +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(); + +?> + + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch/refinements.phtml b/design/frontend/template/instantsearch/refinements.phtml new file mode 100644 index 00000000..ee984e95 --- /dev/null +++ b/design/frontend/template/instantsearch/refinements.phtml @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch/stats.phtml b/design/frontend/template/instantsearch/stats.phtml new file mode 100644 index 00000000..e74134a7 --- /dev/null +++ b/design/frontend/template/instantsearch/stats.phtml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch/wrapper.phtml b/design/frontend/template/instantsearch/wrapper.phtml new file mode 100644 index 00000000..8bb6a3a3 --- /dev/null +++ b/design/frontend/template/instantsearch/wrapper.phtml @@ -0,0 +1,132 @@ +isInstantEnabled() && $config->replaceCategories() && Mage::app()->getRequest()->getControllerName() == 'category') { + $category = Mage::registry('current_category'); + $title = $category->getName(); + + if ($category && $category->getDisplayMode() !== 'PAGE') { + $category->getUrlInstance()->setStore(Mage::app()->getStore()->getStoreId()); + + if ($category->getDisplayMode() == 'PRODUCTS_AND_PAGE') { + $page = $category->getLandingPage(); + $cms_block = Mage::getModel('cms/block')->load($page); + + $description = $category->getDescription(); + $content = $this->getLayout()->createBlock('cms/block')->setBlockId($page)->toHtml(); + + if ($category->getImageUrl()) { + $imgHtml = '

'.$this->escapeHtml($category->getName()).'

'; + $imgHtml = $this->helper('catalog/output')->categoryAttribute($category, $imgHtml, 'image'); + } + } + } +} + +?> + + + \ No newline at end of file From 70a39b5afa475fb00c6d5389a983ac7ee38471b1 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Thu, 7 Jul 2016 17:22:45 +0200 Subject: [PATCH 04/25] Fix duplicate CSS classes --- design/frontend/template/instantsearch/hit.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/design/frontend/template/instantsearch/hit.phtml b/design/frontend/template/instantsearch/hit.phtml index e204386e..c1010403 100644 --- a/design/frontend/template/instantsearch/hit.phtml +++ b/design/frontend/template/instantsearch/hit.phtml @@ -29,8 +29,8 @@ $image_base_url = Mage::getBaseUrl(); {{{ _highlightResult.name.value }}}
-
-
+
+
From 47e234c564b3bbd1cd4884c27e101401f18c36a1 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Mon, 11 Jul 2016 11:28:46 +0200 Subject: [PATCH 05/25] Escape translated JS strings --- code/Helper/Data.php | 11 +++++++++ design/frontend/template/autocomplete.phtml | 11 +++++---- design/frontend/template/instantsearch.phtml | 25 +++++++++++++------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/code/Helper/Data.php b/code/Helper/Data.php index 01de4acc..dc10257a 100644 --- a/code/Helper/Data.php +++ b/code/Helper/Data.php @@ -613,4 +613,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); + } } diff --git a/design/frontend/template/autocomplete.phtml b/design/frontend/template/autocomplete.phtml index d258890e..e0142185 100644 --- a/design/frontend/template/autocomplete.phtml +++ b/design/frontend/template/autocomplete.phtml @@ -3,6 +3,9 @@ /** @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'); @@ -51,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); @@ -66,8 +69,8 @@ if ($config->isDefaultSelector()): ?> algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_que, label: '', name: "suggestions"}); } - algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: __('Categories')); ?>, name: "categories"}); - algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: __('Products')); ?>, name: "products"}); + algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: escapeJsTranslatedString($this, 'Categories'); ?>, name: "categories"}); + algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: escapeJsTranslatedString($this, 'Products'); ?>, name: "products"}); /** Setup autocomplete data sources **/ var sources = [], @@ -102,7 +105,7 @@ if ($config->isDefaultSelector()): ?> }; if (algoliaConfig.removeBranding === false) { - options.templates.footer = ''; + options.templates.footer = ''; } /** Bind autocomplete feature to the input */ diff --git a/design/frontend/template/instantsearch.phtml b/design/frontend/template/instantsearch.phtml index 5fe9457b..de893189 100644 --- a/design/frontend/template/instantsearch.phtml +++ b/design/frontend/template/instantsearch.phtml @@ -1,3 +1,10 @@ + + {% endif %} + + + diff --git a/doc/css/_page.scss b/doc/css/_page.scss index e0f043f8..a39a8bfd 100644 --- a/doc/css/_page.scss +++ b/doc/css/_page.scss @@ -11,7 +11,7 @@ h1[id]:before, h2[id]:before, h3[id]:before, h4[id]:before { .menu { position: fixed; - top: 200px; + top: 100px; width: 200px; list-style-type: none; font-size: .8em; diff --git a/doc/documentation.md b/doc/documentation.md index 9e0860c8..269f5840 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -138,9 +138,30 @@ There you can find table where you can set the attributes you want to send to Al
Configuration of attributes to index
+## Suggestions + +Each time the search is processed in backend of Magento, the query, number of results, number of searches of the query are stored/updated in Magento database. Exactly in catalogsearch_query. This is done automaticly by Magento itself and out extension has nothing to do with it. +Be careful - only backend searches are stored in database. Autocomplete or instant search queries are not inserted into the database. + +When you enable the indexing of suggestions, the extension fetches queries from that table, filter the results according your settings (minimal nuber of results, minimal popularity, ...) and filtered queries pushes into Algolia suggestion index. + +To have correct data in your Algolia suggestion index, you need to have correct data in your catalogsearch_query table. To achieve that you need to have enabled backend search by Algolia. That you can have done by enabling Search and Make SEO request in configuration of Algolia extension in Magento administration. +When you have this options enabled, backend search will be processed by Algolia and data in catalogsearch_query will be updated over time. + +Suggestions are not indexed automatically by the extension. You need to trigger reindex manually or you can put it into a cron tab to be processed automatically. For example every hour: + +```sh +1 * * * * php -f /absolute/path/to/magento/shell/indexer.php -- -reindex search_indexer_suggest +``` + # UI/UX +## Custom theme + +By default the extension tries to override top.search block of the theme template. In case your custom theme doesn't contain top.search block, you need to navigate to **System > Configuration > Algolia Search > Advanced tab** and change DOM selector of your search input. +When you do that, the extension won't try to override top.search block and will only include it's scripts. In this case you will have to update your styles and put your desired look and feel to your autocomplete menu. + ## Auto-completion menu The extension uses [autocomplete.js](https://github.com/algolia/autocomplete.js) library to display the as-you-type auto-completion menu. By default the menu suggests: @@ -226,12 +247,19 @@ More information about customizing widgets you can find in [instantsearch.js doc # Upgrade +It's strongly recommended to use [Modman](https://github.com/colinmollenhour/modman) or [Magento Connect](https://www.magentocommerce.com/magento-connect/search-algolia-search.html) to install the extension. Other installation methods are not supported. + For upgrade to new version, do the following steps: -1. Install the new version of the extension -2. Go to the **System > Configuration > Catalog > Algolia Search** administration panel and save your configuration. **Even if you didn’t change anything.** -3. Force the re-indexing of all indexers -4. Follow any other guidelines specified in the [changelog](https://github.com/algolia/algoliasearch-magento/blob/master/CHANGELOG.md) +1. If you have installed previous version of the extension, uninstall it + - via Magento Connect + - or by Modman command $ modman undeploy algoliasearch-magento +2. Install the new version of the extension + - via Magento Connect + - or by Modman command $ modman clone https://github.com/algolia/algoliasearch-magento +3. Go to the **System > Configuration > Catalog > Algolia Search** administration panel and save your configuration. **Even if you didn’t change anything.** +4. Force the re-indexing of all indexers +5. Follow any other guidelines specified in the [changelog](https://github.com/algolia/algoliasearch-magento/blob/master/CHANGELOG.md) # Developers diff --git a/doc/faq.md b/doc/faq.md index 64313372..02621300 100644 --- a/doc/faq.md +++ b/doc/faq.md @@ -62,6 +62,20 @@ Yes you just need to disable indexing for the store where you do not need Algoli
Enable indexing setting
+## I hit "Reindex" button, but there are still no products in Algolia indices + +In case you have indexing queue enabled, the reindex button will "only" insert indexing jobs to queue database table and not really send them to Algolia. Please make sure you have set queue proccessing correctly and you have set reasonable number of products to be processed in one job. If you set the number od processed products too high the processing script may run out of memory and no products will be indexed. +More information about indexing queue can be found in [documentation](/magento/documentation/#indexing-queue). + +## I cannot find my products by SKU + +Please, make sure you are using the newest version of the extension. And make sure you set SKU as searchable attribute to index in Algolia's extension configuration in Magento backend. + +## I have deleted some products, why are they still appearing in Algolia indices even after full reindex? + +Please, make sure you are using the latest version of the extension. It happens when you update / delete your products directly in database and do not trigger standart Magento hooks. The full reindex then had problem with recognizing deleted products and removing them from Algolia. +This issue was resolved in version 1.6.0. Instruction how to upgrade can be found in [documentation](/magento/documentation/#upgrade). + ## Why are images not showing up? Since Algolia is displaying results without going through the backend of magento, at indexing time we need to generate a link for the url. What magento give you when you are asking for this url is the url of the cached and resized image that you need to display. @@ -113,4 +127,11 @@ But on the other hand it brings two inconveniences: - **Templates:** When the whole page is rendered in your client's web browser it cannot respect your Magento store's custom templates. Templates for instant search page must be customized in the extension's template file. For more information about customizing see [Customization section](/magento/documentation/#customization) in the documentation. - **SEO:** -The extenstion supports only backend search for regular search page and these results can be indexed by search engines like Google, Bing, etc... But because of the frontend implementantion instant search page results on category page cannot be indexed. But there is a workaround. Search parameters of the instant search page are pushed into page's URL. So it is possible to implement backend search base on the URL parameters so the instant search pages can be indexed. But the extension inself do not support this feature out of the box for now. \ No newline at end of file +The extenstion supports only backend search for regular search page and these results can be indexed by search engines like Google, Bing, etc... But because of the frontend implementantion instant search page results on category page cannot be indexed. But there is a workaround. Search parameters of the instant search page are pushed into page's URL. So it is possible to implement backend search base on the URL parameters so the instant search pages can be indexed. But the extension inself do not support this feature out of the box for now. + +## I'm using Magento 2. Is the extension compatible? + +No, the extension is not compatible, but we have Magento 2 extension currently in beta. You can find it here: [https://github.com/algolia/algoliasearch-magento-2](https://github.com/algolia/algoliasearch-magento-2). +Remember, the Magento 2 extension is still in beta and it's not recommended to use it in production unless you really know what you are doing. + +Any feedback on Magento 2 extension is very appreciated. You can submit an issue on GitHub repository or send us any email on [support+magento@algolia.com](mailto:support+magento@algolia.com). \ No newline at end of file From 329f9898055933b5d47d6047f5a36986d6226f24 Mon Sep 17 00:00:00 2001 From: Lucas Bonomi Date: Mon, 11 Jul 2016 18:08:51 +0200 Subject: [PATCH 09/25] Add style to searchbox --- doc/_includes/header.html | 24 +++- doc/_layouts/default.html | 4 +- doc/css/_header.scss | 2 +- doc/css/_search.scss | 87 ++++++++++++ doc/css/docsearch/_docsearch.scss | 41 ++++++ doc/css/docsearch/_searchbox.scss | 218 ++++++++++++++++++++++++++++++ doc/css/main.scss | 6 +- doc/js/header.js | 39 ++++-- 8 files changed, 400 insertions(+), 21 deletions(-) create mode 100644 doc/css/_search.scss create mode 100644 doc/css/docsearch/_docsearch.scss create mode 100644 doc/css/docsearch/_searchbox.scss diff --git a/doc/_includes/header.html b/doc/_includes/header.html index 5484c99b..936f9f38 100644 --- a/doc/_includes/header.html +++ b/doc/_includes/header.html @@ -9,7 +9,29 @@ Magento
- +
    {% assign url = page.url %} {% for link in site.navigation %} diff --git a/doc/_layouts/default.html b/doc/_layouts/default.html index 16b9d058..fa0960b7 100644 --- a/doc/_layouts/default.html +++ b/doc/_layouts/default.html @@ -10,13 +10,13 @@ + - @@ -47,7 +47,7 @@ diff --git a/doc/css/_header.scss b/doc/css/_header.scss index e10ae052..c101becb 100644 --- a/doc/css/_header.scss +++ b/doc/css/_header.scss @@ -81,7 +81,7 @@ vertical-align: middle; } - .ac-nav-menu svg { + .ac-nav-menu li svg { position: relative; top: 6px; width: 28px; diff --git a/doc/css/_search.scss b/doc/css/_search.scss new file mode 100644 index 00000000..b1876738 --- /dev/null +++ b/doc/css/_search.scss @@ -0,0 +1,87 @@ +// Import Searchbox Settings // +/////////////////////////////// +@import 'docsearch/docsearch'; +@import 'docsearch/searchbox'; + +@include searchbox($searchbox-config...); + +.searchbox { + width: inherit; +} +// Search input in the navbar +.search-form { + position: relative; + top: -2px; + + input { + position: relative; + width: 36px; + height: 36px; + } + + // Main autocomplete wrapper + .aa-dropdown-menu { + background-color: #FFFFFF; + border-radius: 0 0 4px 4px; + box-shadow: 0 0 0 4px rgba($dark-blue, .3); + color: $text-color; + font-size: 14px; + margin: 2px 0 0; + padding: 8px; + text-align: left; + width: 510px; + } + // Suggestion category separator + .suggestion-category { + color: $brand-primary; + border-bottom: solid 2px $brand-primary; + font-size: 15px; + font-weight: bold; + padding: 10px 0 2px; + text-align: left; + } + // Use table display for the two columns + .suggestion { + display: table; + width: 100%; + } + em { + background-color: rgba($brand-primary, .2); + color: $dark-blue; + font-style: normal; + } + .suggestion-subcategory-main { + border-right: 1px solid $brand-primary; + display: table-cell; + max-width: 150px; + min-width: 150px; + overflow: hidden; + padding: 10px 15px 10px 10px; + text-align: right; + text-overflow: ellipsis; + vertical-align: top; + width: 150px; + font-weight: bold; + code { + color: $text-color; + } + } + .suggestion-content { + border-bottom: 1px solid rgba($brand-primary, .2); + cursor: pointer; + display: table-cell; + padding: 10px 15px; + } + .aa-cursor .suggestion-content { + background: rgba($brand-primary, .2); + color: $dark-blue; + } + .suggestion-title { + font-weight: bold; + } + .suggestion-text { + font-size: .9em; + line-height: 1.5em; + color: lighten($gray, 20%); + } +} diff --git a/doc/css/docsearch/_docsearch.scss b/doc/css/docsearch/_docsearch.scss new file mode 100644 index 00000000..4079f8ca --- /dev/null +++ b/doc/css/docsearch/_docsearch.scss @@ -0,0 +1,41 @@ +// SEARCHBOX +$searchbox-config: ( + input-width: 200px, + input-height: 36px, + border-width: 2px, + border-radius: 18px, + input-border-color: rgba(#1D96C7,.5), + input-focus-border-color: rgba(#1D96C7,.8), + input-background: #000 !important, + input-focus-background: #000 !important, + font-size: 12px, + placeholder-color: #777, + icon-size: 12px, + icon-position: left, + icon-color: #1D96C7, + icon-background-opacity: 0, + icon-clear-size: 12px +) !default; + +// DROPDOWN +$dropdown-config: ( + main-color: #458EE1, + layout-type: normal, + layout-alignment: right, + layout-width: 800, + background-color: #FFFFFF, + border-radius: 4, + border-width: 1, + border-color: #D9D9D9, + box-shadow: light, + branding-position: bottom, + spacing: compact, + include-desc: yes, + background-category-header: #FFFFFF, + font-size: normal, + header-color: #33363D, + title-color: #02060C, + subtitle-color: #A4A7AE, + text-color: #63676D, + highlight-color: #3881FF +) !default; diff --git a/doc/css/docsearch/_searchbox.scss b/doc/css/docsearch/_searchbox.scss new file mode 100644 index 00000000..f775d612 --- /dev/null +++ b/doc/css/docsearch/_searchbox.scss @@ -0,0 +1,218 @@ +@function even-px($value) { + @if type-of($value) == 'number' { + @if (unitless($value)) { + $value: $value * 1px; + } @else if unit($value) == 'em' { + $value: ($value / 1em * 16px); + } @else if unit($value) == 'pts' { + $value: $value * 1.3333 * 1px; + } @else if unit($value) == '%' { + $value: $value * 16 / 100% * 1px; + }; + $value: round($value); + @if ($value % 2 != 0px) { + $value: $value + 1; + } + @return $value; + } +} + +@mixin searchbox( + $font-size: 90%, + $input-width: 350px, + $input-height: $font-size * 2.4, + $border-width: 1px, + $border-radius: $input-height / 2, + $input-border-color: #CCCCCC, + $input-focus-border-color: #1EC9EA, + $input-background: #000, + $input-focus-background: #FFFFFF, + $placeholder-color: #AAAAAA, + $icon: 'sbx-icon-search-1', + $icon-size: $input-height / 1.6, + $icon-position: left, + $icon-color: #888, + $icon-background: $input-focus-border-color, + $icon-background-opacity: .1, + $icon-clear: 'sbx-icon-clear-1', + $icon-clear-size: $font-size / 1.1 +) { + .searchbox { + display: inline-block; + position: relative; + height: even-px($input-height) !important; + white-space: nowrap; + box-sizing: border-box; + visibility: visible !important; + vertical-align: middle; + + &__wrapper { + width: 100%; + height: 100%; + } + + &__input { + display: inline-block; + transition: box-shadow .4s ease, background .4s ease; + border: 0; + border-radius: even-px($border-radius); + box-shadow: inset 0 0 0 $border-width $input-border-color; + background: $input-background; + padding: 0; + width: $input-height; + height: 36px; + vertical-align: middle; + white-space: normal; + font-size: $font-size; + appearance: none; + color: transparent; + + + &::-webkit-input-placeholder { + color: transparent; + } + + &::placeholder { + color: transparent; + } + + &::-webkit-search-decoration, + &::-webkit-search-cancel-button, + &::-webkit-search-results-button, + &::-webkit-search-results-decoration { + display: none; + } + + &:hover { + box-shadow: inset 0 0 0 $border-width darken($input-border-color, 10%); + } + + &:focus, + &:active, + &.filled, + &.search-active { + padding-right: if($icon-position == 'right', even-px($input-height) + even-px($icon-clear-size) + 8px, even-px($input-height * .8)) + + if($icon-background-opacity == 0, 0, even-px($font-size)); + padding-left: if($icon-position == 'right', + even-px($font-size / 2) + even-px($border-radius / 2), + even-px($input-height) + if($icon-background-opacity == 0, 0, even-px($font-size * 1.2))); + width: 100%; + outline: 0; + box-shadow: inset 0 0 0 $border-width $input-focus-border-color; + background: $input-focus-background; + color: #FFFFFF; + &::-webkit-input-placeholder { + color: #777; + } + &::placeholder { + color: #777; + } + } + } + + &__submit { + position: absolute; + top: 0; + margin: 0; + border: 0; + border-radius: if($icon-position == 'right', 0 $border-radius $border-radius 0, $border-radius 0 0 $border-radius); + background-color: rgba($icon-background, $icon-background-opacity); + padding: 0; + width: even-px($input-height) + if($icon-background-opacity == 0, 0, even-px($font-size / 2)); + line-height: even-px($input-height); + height: 100%; + vertical-align: middle; + text-align: center; + font-size: inherit; + user-select: none; + pointer-events: none; + @if $icon-position == 'right' { + right: 0; + left: inherit; + } @else { + right: inherit; + left: 0; + } + + // Helper for vertical alignement of the icon + &::before { + display: inline-block; + margin-right: -4px; + height: 100%; + vertical-align: middle; + content: ''; + } + + &:hover, + &:active { + cursor: pointer; + } + + &:focus { + outline: 0; + } + + svg { + width: even-px($icon-size); + height: even-px($icon-size); + vertical-align: middle; + fill: $icon-color; + } + } + + &__reset { + display: block; + position: absolute; + top: (even-px($input-height) - even-px($icon-clear-size)) / 2 - 4px; + right: if($icon-position == 'right', + even-px($input-height) + if($icon-background-opacity == 0, 0 , even-px($font-size)), + (even-px($input-height) - even-px($icon-clear-size)) / 2 - 4px); + margin: 0; + border: 0; + background: none; + cursor: pointer; + padding: 0; + font-size: inherit; + user-select: none; + fill: rgba($icon-color, .5); + + &.hide { + display: none; + } + + &:focus { + outline: 0; + } + + svg { + display: block; + margin: 4px; + width: even-px($icon-clear-size); + height: even-px($icon-clear-size); + } + } + + &__input:valid ~ &__reset { + display: block !important; + &.hide { + display: block !important; + } + animation-name: sbx-reset-in; + animation-duration: .15s; + } + + @at-root { + @keyframes sbx-reset-in { + 0% { + transform: translate3d(-20%, 0, 0); + opacity: 0; + } + + 100% { + transform: none; + opacity: 1; + } + } + } + } +} diff --git a/doc/css/main.scss b/doc/css/main.scss index 46e6a11b..5fcd1ea5 100644 --- a/doc/css/main.scss +++ b/doc/css/main.scss @@ -7,9 +7,11 @@ @import "bootstrap"; @import "mixin"; @import "syntax-highlighting"; -@import "helper"; - @import "header"; @import "home"; @import "page"; @import "footer"; +@import "search"; +@import "helper"; + + diff --git a/doc/js/header.js b/doc/js/header.js index 80625ca4..793910b5 100644 --- a/doc/js/header.js +++ b/doc/js/header.js @@ -1,28 +1,37 @@ $(document).ready(function(){ - function responsiveNavigation() { - var navigation = document.querySelector('.ac-nav'); - var links = navigation.querySelectorAll('a'); - var navigationAsSelect = document.createElement('select'); - if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) { - navigationAsSelect.classList.add('display-on-small', 'device'); + $('#doc-search').on('keyup', function(){ + if($(this).val()) { + $('.searchbox__reset').removeClass('hide') + } + }).on('blur', function(){ + $('.searchbox__reset').addClass('hide') + }); + + function responsiveNavigation() { + var navigation = document.querySelector('.ac-nav'); + var links = navigation.querySelectorAll('a'); + var navigationAsSelect = document.createElement('select'); + + if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) { + navigationAsSelect.classList.add('display-on-small', 'device'); } else { - navigationAsSelect.classList.add('display-on-small'); + navigationAsSelect.classList.add('display-on-small'); } for (var i = 0; i < links.length; i++) { - var option = document.createElement('option'); - option.text = links[i].title; - option.value = links[i].href; - option.selected = true; - navigationAsSelect.appendChild(option); + var option = document.createElement('option'); + option.text = links[i].title; + option.value = links[i].href; + option.selected = true; + navigationAsSelect.appendChild(option); } navigation.appendChild(navigationAsSelect); navigation.addEventListener('change', function () { - return window.location = e.target.value; + return window.location = e.target.value; }); -} -responsiveNavigation(); + } + responsiveNavigation(); }); \ No newline at end of file From d37675dba3c192e10d878ac09c529e8069a2212e Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Mon, 11 Jul 2016 18:18:27 +0200 Subject: [PATCH 10/25] Typos --- doc/documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/documentation.md b/doc/documentation.md index 269f5840..82cc0675 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -160,7 +160,7 @@ Suggestions are not indexed automatically by the extension. You need to trigger ## Custom theme By default the extension tries to override top.search block of the theme template. In case your custom theme doesn't contain top.search block, you need to navigate to **System > Configuration > Algolia Search > Advanced tab** and change DOM selector of your search input. -When you do that, the extension won't try to override top.search block and will only include it's scripts. In this case you will have to update your styles and put your desired look and feel to your autocomplete menu. +When you do that, the extension won't try to override top.search block and will only include it's scripts. In this case you will have to update your styles and put your desired look and feel to your auto-completion menu. ## Auto-completion menu From 2566b29776101044429b68ceb22f4b8f0f5d5ca1 Mon Sep 17 00:00:00 2001 From: Lucas Bonomi Date: Wed, 13 Jul 2016 17:57:11 +0200 Subject: [PATCH 11/25] New style for dropdown --- doc/_layouts/default.html | 1 - doc/css/_search.scss | 140 ++++----- doc/css/docsearch/_docsearch.scss | 41 --- doc/css/docsearch/_dropdown.scss | 477 ++++++++++++++++++++++++++++++ doc/css/docsearch/_searchbox.scss | 2 + doc/css/docsearch/_variables.scss | 41 +++ 6 files changed, 579 insertions(+), 123 deletions(-) create mode 100644 doc/css/docsearch/_dropdown.scss create mode 100644 doc/css/docsearch/_variables.scss diff --git a/doc/_layouts/default.html b/doc/_layouts/default.html index fa0960b7..310acb67 100644 --- a/doc/_layouts/default.html +++ b/doc/_layouts/default.html @@ -10,7 +10,6 @@ - diff --git a/doc/css/_search.scss b/doc/css/_search.scss index b1876738..a59c8dd3 100644 --- a/doc/css/_search.scss +++ b/doc/css/_search.scss @@ -1,87 +1,65 @@ -// Import Searchbox Settings // -/////////////////////////////// -@import 'docsearch/docsearch'; -@import 'docsearch/searchbox'; +@import "docsearch/variables"; +@import "docsearch/dropdown"; +@import "docsearch/searchbox"; -@include searchbox($searchbox-config...); +$searchbox: true!default; -.searchbox { - width: inherit; +@if($searchbox == true){ + @include searchbox($searchbox-config...); } -// Search input in the navbar -.search-form { - position: relative; - top: -2px; - input { - position: relative; - width: 36px; - height: 36px; - } +@include dropdown($dropdown-config...); - // Main autocomplete wrapper - .aa-dropdown-menu { - background-color: #FFFFFF; - border-radius: 0 0 4px 4px; - box-shadow: 0 0 0 4px rgba($dark-blue, .3); - color: $text-color; - font-size: 14px; - margin: 2px 0 0; - padding: 8px; - text-align: left; - width: 510px; - } - // Suggestion category separator - .suggestion-category { - color: $brand-primary; - border-bottom: solid 2px $brand-primary; - font-size: 15px; - font-weight: bold; - padding: 10px 0 2px; - text-align: left; - } - // Use table display for the two columns - .suggestion { - display: table; - width: 100%; - } - em { - background-color: rgba($brand-primary, .2); - color: $dark-blue; - font-style: normal; - } - .suggestion-subcategory-main { - border-right: 1px solid $brand-primary; - display: table-cell; - max-width: 150px; - min-width: 150px; - overflow: hidden; - padding: 10px 15px 10px 10px; - text-align: right; - text-overflow: ellipsis; - vertical-align: top; - width: 150px; - font-weight: bold; - code { - color: $text-color; - } - } - .suggestion-content { - border-bottom: 1px solid rgba($brand-primary, .2); - cursor: pointer; - display: table-cell; - padding: 10px 15px; - } - .aa-cursor .suggestion-content { - background: rgba($brand-primary, .2); - color: $dark-blue; - } - .suggestion-title { - font-weight: bold; - } - .suggestion-text { - font-size: .9em; - line-height: 1.5em; - color: lighten($gray, 20%); - } +.algolia-autocomplete .ds-dropdown-menu { + line-height: 32px; } + +.algolia-autocomplete .ds-dropdown-menu [class^="ds-dataset-"] { + min-width: 500px; + padding: 0; +} +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0 !important; +} + +.algolia-autocomplete .algolia-docsearch-suggestion.algolia-docsearch-suggestion__secondary .algolia-docsearch-suggestion--subcategory-column { + display: none !important; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content:before { + display: none !important; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + width: 100% !important; + padding: 0 6px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + padding: 0 !important; + margin-bottom: 6px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + line-height: 1.5; + padding: 0 16px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + font-weight: 600; + width: calc(100% - 32px) !important; + margin-left: 16px !important; + padding: 0 !important; +} + +.algolia-docsearch-suggestion--title { + font-weight: 600; + color: rgba(black, 0.7) !important; + margin-left: -6px; + padding: 0 16px; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + float: right; + margin: -4px 8px; +} \ No newline at end of file diff --git a/doc/css/docsearch/_docsearch.scss b/doc/css/docsearch/_docsearch.scss index 4079f8ca..e69de29b 100644 --- a/doc/css/docsearch/_docsearch.scss +++ b/doc/css/docsearch/_docsearch.scss @@ -1,41 +0,0 @@ -// SEARCHBOX -$searchbox-config: ( - input-width: 200px, - input-height: 36px, - border-width: 2px, - border-radius: 18px, - input-border-color: rgba(#1D96C7,.5), - input-focus-border-color: rgba(#1D96C7,.8), - input-background: #000 !important, - input-focus-background: #000 !important, - font-size: 12px, - placeholder-color: #777, - icon-size: 12px, - icon-position: left, - icon-color: #1D96C7, - icon-background-opacity: 0, - icon-clear-size: 12px -) !default; - -// DROPDOWN -$dropdown-config: ( - main-color: #458EE1, - layout-type: normal, - layout-alignment: right, - layout-width: 800, - background-color: #FFFFFF, - border-radius: 4, - border-width: 1, - border-color: #D9D9D9, - box-shadow: light, - branding-position: bottom, - spacing: compact, - include-desc: yes, - background-category-header: #FFFFFF, - font-size: normal, - header-color: #33363D, - title-color: #02060C, - subtitle-color: #A4A7AE, - text-color: #63676D, - highlight-color: #3881FF -) !default; diff --git a/doc/css/docsearch/_dropdown.scss b/doc/css/docsearch/_dropdown.scss new file mode 100644 index 00000000..bfd423c1 --- /dev/null +++ b/doc/css/docsearch/_dropdown.scss @@ -0,0 +1,477 @@ +// Detect lightness +@function detectLightness($color) { + @if (lightness($color) > 60) { + @return mix($color, #000, 90%); + } @else { + @return mix($color, #fff, 90%); + } +} + +// Spacing +@function spacing($type) { + @if $type == 'compact' { + @return 12px; + } + @if $type == 'spacious' { + @return 22px; + } + @else { + @return 16px; + } +} + +// Description +@function desc($display) { + @if $display == false { + @return none; + } + @else { + @return block; + } +} + +// Layout type +@mixin layout-width($type) { + @if $type == 'small' { + max-width: 500px; + min-width: 400px; + } + @if $type == 'normal' { + max-width: 600px; + min-width: 500px; + } + @if $type == 'large' { + max-width: 800px; + min-width: 600px; + } + @if $type == 'full' { + width: 100%; + } +} + +// Alignement type +@mixin alignment-type($type) { + @if $type == 'left' { + left: 0 !important; + right: inherit !important; + } + @if $type == 'right' { + right: 0 !important; + left: inherit !important; + } + @if $type == 'center' { + left: 0 !important; + right: 0 !important; + margin: auto !important; + } +} + +// Mixin - Shadow type +@mixin shadow-type($type) { + @if $type == 'light' { + box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1) ; + } + @if $type == 'heavy' { + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + } +} + +// Mixin - highlight +@function set-highlight($highlight, $color) { + @if $highlight == 1 and lightness($color) < 60 { + @return mix(#fff, $color, 90%); + } + @else { + @return darken(detectLightness($color), 30%); + } +} + +@mixin dropdown( + $main-color: #458EE1, + $layout-width: normal, + $layout-type: normal, + $layout-alignment: 'align', + $background-color: #FFFFFF, + $border-radius: 4, + $border-width: 1, + $border-color: #d9d9d9, + $box-shadow: light, + $branding-position: bottom, + $font-size: normal, + $header-color: #33363D , + $title-color: #02060C, + $subtitle-color: #A4A7AE, + $text-color: #63676D, + $highlight-color: #3881FF, + $spacing: normal, + $include-desc: true, + $background-category-header: #FFFFFF, + $highlight-opacity: .1, + $highlight-type: 'underline' +){ + + $header-size: 1em; + $title-size: .9em; + $text-size: .85em; + $subtitle-size: .9em; + $padding: spacing($spacing); + + @if $font-size == 'small' { + $header-size: .95em; + $title-size: .8em; + $text-size: .75em; + $subtitle-size: .8em; + } + + @else if $font-size == 'large' { + $header-size: 1.1em; + $title-size: 1em; + $text-size: .9em; + $subtitle-size: 1em; + } + + .algolia-autocomplete { + + &.algolia-autocomplete-right .ds-dropdown-menu{ + @include alignment-type(right); + &:before { + right: 48px; + } + } + + &.algolia-autocomplete-left .ds-dropdown-menu{ + @include alignment-type(left); + &:before { + left: 48px; + } + } + + // Dropdown wrapper + .ds-dropdown-menu { + position: relative; + top: -6px; + border-radius: $border-radius+px; + margin: 6px 0 0; + padding: 0; + text-align: left; + height: auto; + position: relative; + background: transparent; + border: none; + z-index: 999; + @include layout-width($layout-width); + @include shadow-type($box-shadow); + + // Arrow + &:before { + display: block; + position: absolute; + content: ''; + width: 14px; + height: 14px; + background: $background-color; + z-index:1000; + top: -7px; + border-top: $border-width+px solid $border-color; + border-right: $border-width+px solid $border-color; + transform: rotate(-45deg); + border-radius: 2px; + } + + .ds-suggestions { + position: relative; + z-index: 1000; + margin-top: $padding/2; + } + + .ds-suggestion{ + cursor: pointer; + + &.ds-cursor { + .algolia-docsearch-suggestion.suggestion-layout-simple { + background-color: rgba($main-color,.05); + } + + .algolia-docsearch-suggestion:not(.suggestion-layout-simple){ + .algolia-docsearch-suggestion--content{ + background-color: rgba($main-color,.05); + } + } + } + } + + [class^="ds-dataset-"] { + position: relative; + border: solid $border-width+px $border-color; + background: $background-color; + border-radius: $border-radius+px; + overflow: auto; + padding: 0 $padding/2 $padding/2; + } + + // Inner-grid setup + * { + box-sizing: border-box; + } + } + + // Each suggestion item is wrapped + .algolia-docsearch-suggestion { + position: relative; + padding: 0 $padding/2; + background: $background-color; + color: $title-color; + overflow: hidden; + + @if $highlight-type == basic { + &--highlight { + color: $main-color; + background-color: rgba($main-color, $highlight-opacity); + } + + .algolia-docsearch-suggestion--item-header .algolia-docsearch-suggestion--highlight{ + color: inherit; + background: inherit; + } + } + + @else { + &--highlight { + color: set-highlight($highlight-opacity, $main-color); + background: rgba(mix($main-color, #fff, 60%), $highlight-opacity); + padding: 0.1em 0.05em; + } + + &--category-header .algolia-docsearch-suggestion--category-header-lvl0 .algolia-docsearch-suggestion--highlight, + &--category-header .algolia-docsearch-suggestion--category-header-lvl1 .algolia-docsearch-suggestion--highlight { + color: inherit; + background: inherit; + } + + &--text .algolia-docsearch-suggestion--highlight{ + padding: 0 0 1px; + background: inherit; + box-shadow: inset 0 -2px 0 0 rgba($main-color, 0.8); + color: inherit; + } + } + + &--content { + display: block; + float: right; + width: 70%; + position: relative; + padding: $padding/3 0 $padding/3 $padding/1.5; + cursor: pointer; + + &:before { + content: ''; + position: absolute; + display: block; + top: 0; + height: 100%; + width: 1px; + background: #ddd; + left: -1px; + } + } + + &--category-header { + position: relative; + border-bottom: 1px solid #ddd; + display: none; + margin-top: $padding/2; + padding: $padding/4 0; + font-size: $header-size; + color: $header-color; + } + + &--wrapper { + width: 100%; + float: left; + padding: $padding/2 0 0 0; + } + + &--subcategory-column { + float: left; + width: 30%; + display: none; + padding-left: 0; + text-align: right; + position: relative; + padding: $padding/3 $padding/1.5; + color: $subtitle-color; + font-size: $subtitle-size; + word-wrap: break-word; + + &:before { + content: ''; + position: absolute; + display: block; + top: 0; + height: 100%; + width: 1px; + background: #ddd; + right: 0; + } + + .algolia-docsearch-suggestion--highlight { + background-color: inherit; + color: inherit; + } + } + + &--subcategory-inline { + display: none; + } + + &--title { + margin-bottom: $padding/4; + color: $title-color; + font-size: $title-size; + font-weight: bold; + } + + &--text { + display: desc($include-desc); + line-height: 1.2em; + font-size: $text-size; + color: $text-color; + } + + &--no-results{ + width: 100%; + padding: $padding/2 0; + text-align: center; + font-size: 1.2em; + + &::before{ + display: none; + } + } + + // Rules to display categories and subcategories + &.algolia-docsearch-suggestion__main .algolia-docsearch-suggestion--category-header { + display: block; + } + + &.algolia-docsearch-suggestion__secondary .algolia-docsearch-suggestion--subcategory-column { + display: block; + } + } + + //Simple layout (no column) + .suggestion-layout-simple{ + + &.algolia-docsearch-suggestion { + border-bottom: solid 1px #eee; + padding: $padding/2; + margin: 0; + } + + .algolia-docsearch-suggestion { + &--content { + width: 100%; + padding: 0; + + &::before{ + display: none; + } + } + + &--category-header { + margin: 0; + padding: 0; + display: block; + width: 100%; + border: none; + + &-lvl0 { + opacity: .6; + font-size: $text-size; + } + + &-lvl1{ + opacity: .6; + font-size: $text-size; + + &::before{ + background-image: url('data:image/svg+xml;utf8,'); + content: ''; + width: 10px; + height: 10px; + display: inline-block; + } + } + } + + &--wrapper { + width: 100%; + float: left; + margin: 0; + padding: 0; + } + + &--subcategory-column, + &--duplicate-content, + &--subcategory-inline { + display: none!important; + } + + &--title { + margin: 0; + color: $main-color; + font-size: $title-size; + font-weight: normal; + + &::before{ + content: "#"; + font-weight: bold; + color: $main-color; + display: inline-block; + } + } + + &--text { + margin: $padding/4 0 0; + display: desc($include-desc); + line-height: 1.4em; + padding: $padding/3 $padding/2; + background: #f8f8f8; + font-size: $text-size; + opacity: .8; + + .algolia-docsearch-suggestion--highlight { + color: darken($text-color,15%); + font-weight: bold; + box-shadow: none; + } + } + } + } + + // powered by + .algolia-docsearch-footer { + width: 100px; + height: 20px; + z-index: 2000; + margin-top: $padding/1.5; + float: right; + font-size: 0; + line-height: 0; + + &--logo { + background-image: url('data:image/svg+xml;utf8,'); + background-repeat: no-repeat; + background-position: center; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + padding: 0!important; + width: 100%; + height: 100%; + display: block; + } + } + } +} \ No newline at end of file diff --git a/doc/css/docsearch/_searchbox.scss b/doc/css/docsearch/_searchbox.scss index f775d612..b11ad81c 100644 --- a/doc/css/docsearch/_searchbox.scss +++ b/doc/css/docsearch/_searchbox.scss @@ -216,3 +216,5 @@ } } } + + diff --git a/doc/css/docsearch/_variables.scss b/doc/css/docsearch/_variables.scss new file mode 100644 index 00000000..4079f8ca --- /dev/null +++ b/doc/css/docsearch/_variables.scss @@ -0,0 +1,41 @@ +// SEARCHBOX +$searchbox-config: ( + input-width: 200px, + input-height: 36px, + border-width: 2px, + border-radius: 18px, + input-border-color: rgba(#1D96C7,.5), + input-focus-border-color: rgba(#1D96C7,.8), + input-background: #000 !important, + input-focus-background: #000 !important, + font-size: 12px, + placeholder-color: #777, + icon-size: 12px, + icon-position: left, + icon-color: #1D96C7, + icon-background-opacity: 0, + icon-clear-size: 12px +) !default; + +// DROPDOWN +$dropdown-config: ( + main-color: #458EE1, + layout-type: normal, + layout-alignment: right, + layout-width: 800, + background-color: #FFFFFF, + border-radius: 4, + border-width: 1, + border-color: #D9D9D9, + box-shadow: light, + branding-position: bottom, + spacing: compact, + include-desc: yes, + background-category-header: #FFFFFF, + font-size: normal, + header-color: #33363D, + title-color: #02060C, + subtitle-color: #A4A7AE, + text-color: #63676D, + highlight-color: #3881FF +) !default; From b60ef9b3769ff772897aad1ca7baed9195dcc7cb Mon Sep 17 00:00:00 2001 From: Lucas Bonomi Date: Fri, 15 Jul 2016 12:11:25 +0200 Subject: [PATCH 12/25] Fix buggy docsearch dropdown (#497) Fix buggy docsearch dropdown --- doc/_layouts/default.html | 1 + doc/css/_search.scss | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/doc/_layouts/default.html b/doc/_layouts/default.html index 310acb67..fa0960b7 100644 --- a/doc/_layouts/default.html +++ b/doc/_layouts/default.html @@ -10,6 +10,7 @@ + diff --git a/doc/css/_search.scss b/doc/css/_search.scss index a59c8dd3..05e9f6c3 100644 --- a/doc/css/_search.scss +++ b/doc/css/_search.scss @@ -10,6 +10,10 @@ $searchbox: true!default; @include dropdown($dropdown-config...); +.searchbox { + width: inherit; +} + .algolia-autocomplete .ds-dropdown-menu { line-height: 32px; } From bca50f50d2b205094c986c41927f82ba14989ed0 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Tue, 5 Jul 2016 17:03:42 +0200 Subject: [PATCH 13/25] Fix synonyms when there are only spaces --- code/Helper/Entity/Producthelper.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/Helper/Entity/Producthelper.php b/code/Helper/Entity/Producthelper.php index 2cca9a1b..9c25fa10 100644 --- a/code/Helper/Entity/Producthelper.php +++ b/code/Helper/Entity/Producthelper.php @@ -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', @@ -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', From 62ef71a71ce880551c6ffcd4e144a7e5fcd7c153 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Wed, 6 Jul 2016 15:06:01 +0200 Subject: [PATCH 14/25] Move locale CSV file to en_US directory and change default language of container Magento to en_US --- dev/Dockerfile | 2 +- dev/bin/algoliasearch.xml | 2 +- locale/{en_GB => en_US}/Algolia_Algoliasearch.csv | 0 modman | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename locale/{en_GB => en_US}/Algolia_Algoliasearch.csv (100%) diff --git a/dev/Dockerfile b/dev/Dockerfile index a7b3e05d..9637f9b4 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -42,7 +42,7 @@ RUN chown -R www-data:www-data /var/www/htdocs ## database setup RUN service mysql start && (echo "CREATE DATABASE magento" | mysql -u root --password=P4ssw0rd) && mysql -u root --password=P4ssw0rd magento < /tmp/magento-sample-data-1.9.0.0/magento_sample_data_for_1.9.0.0.sql && service mysql stop -RUN service mysql start && MYSQL_HOST=127.0.0.1 MYSQL_USER=root MYSQL_PASSWORD=P4ssw0rd MYSQL_DATABASE=magento MAGENTO_LOCALE=en_GB MAGENTO_TIMEZONE=Europe/Paris MAGENTO_DEFAULT_CURRENCY=USD MAGENTO_URL=http://mymagentostore.com MAGENTO_ADMIN_FIRSTNAME=Admin MAGENTO_ADMIN_LASTNAME=MyStore MAGENTO_ADMIN_EMAIL=amdin@mymagentostore.com MAGENTO_ADMIN_USERNAME=admin MAGENTO_ADMIN_PASSWORD=magentorocks1 /usr/local/bin/install-magento && service mysql stop +RUN service mysql start && MYSQL_HOST=127.0.0.1 MYSQL_USER=root MYSQL_PASSWORD=P4ssw0rd MYSQL_DATABASE=magento MAGENTO_LOCALE=en_US MAGENTO_TIMEZONE=Europe/Paris MAGENTO_DEFAULT_CURRENCY=USD MAGENTO_URL=http://mymagentostore.com MAGENTO_ADMIN_FIRSTNAME=Admin MAGENTO_ADMIN_LASTNAME=MyStore MAGENTO_ADMIN_EMAIL=amdin@mymagentostore.com MAGENTO_ADMIN_USERNAME=admin MAGENTO_ADMIN_PASSWORD=magentorocks1 /usr/local/bin/install-magento && service mysql stop ## disable cache RUN service mysql start && n98-magerun --root-dir=/var/www/htdocs cache:flush && n98-magerun --root-dir=/var/www/htdocs cache:disable && service mysql stop diff --git a/dev/bin/algoliasearch.xml b/dev/bin/algoliasearch.xml index 775a9b2e..191f0783 100755 --- a/dev/bin/algoliasearch.xml +++ b/dev/bin/algoliasearch.xml @@ -90,7 +90,7 @@ lib/AlgoliaSearch adminhtml/default/default/template/algoliasearch adminhtml/default/default/layout/algoliasearch.xml - en_GB/Algolia_Algoliasearch.csv + en_US/Algolia_Algoliasearch.csv file diff --git a/locale/en_GB/Algolia_Algoliasearch.csv b/locale/en_US/Algolia_Algoliasearch.csv similarity index 100% rename from locale/en_GB/Algolia_Algoliasearch.csv rename to locale/en_US/Algolia_Algoliasearch.csv diff --git a/modman b/modman index 6ddd7061..02a1df8d 100644 --- a/modman +++ b/modman @@ -10,7 +10,7 @@ design/frontend/layout/algoliasearch.xml app/design/frontend/base/default/lay design/frontend/template app/design/frontend/base/default/template/algoliasearch design/adminhtml/layout/algoliasearch.xml app/design/adminhtml/default/default/layout/algoliasearch.xml design/adminhtml/template app/design/adminhtml/default/default/template/algoliasearch -locale/en_GB/Algolia_Algoliasearch.csv app/locale/en_GB/Algolia_Algoliasearch.csv +locale/en_US/Algolia_Algoliasearch.csv app/locale/en_US/Algolia_Algoliasearch.csv skin skin/frontend/base/default/algoliasearch js js/algoliasearch lib/AlgoliaSearch lib/AlgoliaSearch/ \ No newline at end of file From 0b97a4c47994aa44f5366e482151dc00e88bcb90 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Thu, 7 Jul 2016 16:41:40 +0200 Subject: [PATCH 15/25] Separate autocomplete and instantsearch templates --- design/frontend/layout/algoliasearch.xml | 32 +++ design/frontend/template/autocomplete.phtml | 143 ----------- .../template/autocomplete/attribute.phtml | 9 + .../template/autocomplete/category.phtml | 37 +++ .../frontend/template/autocomplete/menu.phtml | 16 ++ .../frontend/template/autocomplete/page.phtml | 14 + .../template/autocomplete/product.phtml | 54 ++++ .../template/autocomplete/suggestion.phtml | 20 ++ design/frontend/template/instantsearch.phtml | 239 ------------------ .../template/instantsearch/facet.phtml | 8 + .../frontend/template/instantsearch/hit.phtml | 76 ++++++ .../template/instantsearch/refinements.phtml | 16 ++ .../template/instantsearch/stats.phtml | 6 + .../template/instantsearch/wrapper.phtml | 132 ++++++++++ 14 files changed, 420 insertions(+), 382 deletions(-) create mode 100644 design/frontend/template/autocomplete/attribute.phtml create mode 100644 design/frontend/template/autocomplete/category.phtml create mode 100644 design/frontend/template/autocomplete/menu.phtml create mode 100644 design/frontend/template/autocomplete/page.phtml create mode 100644 design/frontend/template/autocomplete/product.phtml create mode 100644 design/frontend/template/autocomplete/suggestion.phtml create mode 100644 design/frontend/template/instantsearch/facet.phtml create mode 100644 design/frontend/template/instantsearch/hit.phtml create mode 100644 design/frontend/template/instantsearch/refinements.phtml create mode 100644 design/frontend/template/instantsearch/stats.phtml create mode 100644 design/frontend/template/instantsearch/wrapper.phtml diff --git a/design/frontend/layout/algoliasearch.xml b/design/frontend/layout/algoliasearch.xml index 429be7f7..604136e7 100644 --- a/design/frontend/layout/algoliasearch.xml +++ b/design/frontend/layout/algoliasearch.xml @@ -30,6 +30,22 @@ + + + + + + + + + + + + + + + + @@ -37,5 +53,21 @@ + + + + + + + + + + + + + + + + diff --git a/design/frontend/template/autocomplete.phtml b/design/frontend/template/autocomplete.phtml index 5d728bf9..d258890e 100644 --- a/design/frontend/template/autocomplete.phtml +++ b/design/frontend/template/autocomplete.phtml @@ -6,15 +6,6 @@ $config = Mage::helper('algoliasearch/config'); /** @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 **/ @@ -35,140 +26,6 @@ if ($config->isDefaultSelector()): ?> - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/design/frontend/template/autocomplete/category.phtml b/design/frontend/template/autocomplete/category.phtml new file mode 100644 index 00000000..b4787ecb --- /dev/null +++ b/design/frontend/template/autocomplete/category.phtml @@ -0,0 +1,37 @@ + + + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/menu.phtml b/design/frontend/template/autocomplete/menu.phtml new file mode 100644 index 00000000..cc3bf19b --- /dev/null +++ b/design/frontend/template/autocomplete/menu.phtml @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/page.phtml b/design/frontend/template/autocomplete/page.phtml new file mode 100644 index 00000000..71d6a471 --- /dev/null +++ b/design/frontend/template/autocomplete/page.phtml @@ -0,0 +1,14 @@ + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/product.phtml b/design/frontend/template/autocomplete/product.phtml new file mode 100644 index 00000000..50b34629 --- /dev/null +++ b/design/frontend/template/autocomplete/product.phtml @@ -0,0 +1,54 @@ +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(); + +?> + + + \ No newline at end of file diff --git a/design/frontend/template/autocomplete/suggestion.phtml b/design/frontend/template/autocomplete/suggestion.phtml new file mode 100644 index 00000000..f46d930a --- /dev/null +++ b/design/frontend/template/autocomplete/suggestion.phtml @@ -0,0 +1,20 @@ + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch.phtml b/design/frontend/template/instantsearch.phtml index 63d837a2..5fe9457b 100644 --- a/design/frontend/template/instantsearch.phtml +++ b/design/frontend/template/instantsearch.phtml @@ -1,242 +1,3 @@ -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(); - -$title = ''; -$description = ''; -$content = ''; -$imgHtml = ''; - -if ($config->isInstantEnabled() && $config->replaceCategories() && Mage::app()->getRequest()->getControllerName() == 'category') { - $category = Mage::registry('current_category'); - $title = $category->getName(); - - if ($category && $category->getDisplayMode() !== 'PAGE') { - $category->getUrlInstance()->setStore(Mage::app()->getStore()->getStoreId()); - - if ($category->getDisplayMode() == 'PRODUCTS_AND_PAGE') { - $page = $category->getLandingPage(); - $cms_block = Mage::getModel('cms/block')->load($page); - - $description = $category->getDescription(); - $content = $this->getLayout()->createBlock('cms/block')->setBlockId($page)->toHtml(); - - if ($category->getImageUrl()) { - $imgHtml = '

    '.$this->escapeHtml($category->getName()).'

    '; - $imgHtml = $this->helper('catalog/output')->categoryAttribute($category, $imgHtml, 'image'); - } - } - } -} - -?> - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/design/frontend/template/instantsearch/hit.phtml b/design/frontend/template/instantsearch/hit.phtml new file mode 100644 index 00000000..e204386e --- /dev/null +++ b/design/frontend/template/instantsearch/hit.phtml @@ -0,0 +1,76 @@ +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(); + +?> + + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch/refinements.phtml b/design/frontend/template/instantsearch/refinements.phtml new file mode 100644 index 00000000..ee984e95 --- /dev/null +++ b/design/frontend/template/instantsearch/refinements.phtml @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch/stats.phtml b/design/frontend/template/instantsearch/stats.phtml new file mode 100644 index 00000000..e74134a7 --- /dev/null +++ b/design/frontend/template/instantsearch/stats.phtml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/design/frontend/template/instantsearch/wrapper.phtml b/design/frontend/template/instantsearch/wrapper.phtml new file mode 100644 index 00000000..8bb6a3a3 --- /dev/null +++ b/design/frontend/template/instantsearch/wrapper.phtml @@ -0,0 +1,132 @@ +isInstantEnabled() && $config->replaceCategories() && Mage::app()->getRequest()->getControllerName() == 'category') { + $category = Mage::registry('current_category'); + $title = $category->getName(); + + if ($category && $category->getDisplayMode() !== 'PAGE') { + $category->getUrlInstance()->setStore(Mage::app()->getStore()->getStoreId()); + + if ($category->getDisplayMode() == 'PRODUCTS_AND_PAGE') { + $page = $category->getLandingPage(); + $cms_block = Mage::getModel('cms/block')->load($page); + + $description = $category->getDescription(); + $content = $this->getLayout()->createBlock('cms/block')->setBlockId($page)->toHtml(); + + if ($category->getImageUrl()) { + $imgHtml = '

    '.$this->escapeHtml($category->getName()).'

    '; + $imgHtml = $this->helper('catalog/output')->categoryAttribute($category, $imgHtml, 'image'); + } + } + } +} + +?> + + + \ No newline at end of file From 2edabb712093b6dcb8103d3ad9dc77d0f9151b7f Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Thu, 7 Jul 2016 17:22:45 +0200 Subject: [PATCH 16/25] Fix duplicate CSS classes --- design/frontend/template/instantsearch/hit.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/design/frontend/template/instantsearch/hit.phtml b/design/frontend/template/instantsearch/hit.phtml index e204386e..c1010403 100644 --- a/design/frontend/template/instantsearch/hit.phtml +++ b/design/frontend/template/instantsearch/hit.phtml @@ -29,8 +29,8 @@ $image_base_url = Mage::getBaseUrl(); {{{ _highlightResult.name.value }}}
    -
    -
    +
    +
    From 334deacc4725603011ac3298f3f696af375f2e67 Mon Sep 17 00:00:00 2001 From: Jan Petr Date: Mon, 11 Jul 2016 11:28:46 +0200 Subject: [PATCH 17/25] Escape translated JS strings --- code/Helper/Data.php | 11 +++++++++ design/frontend/template/autocomplete.phtml | 11 +++++---- design/frontend/template/instantsearch.phtml | 25 +++++++++++++------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/code/Helper/Data.php b/code/Helper/Data.php index 01de4acc..dc10257a 100644 --- a/code/Helper/Data.php +++ b/code/Helper/Data.php @@ -613,4 +613,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); + } } diff --git a/design/frontend/template/autocomplete.phtml b/design/frontend/template/autocomplete.phtml index d258890e..e0142185 100644 --- a/design/frontend/template/autocomplete.phtml +++ b/design/frontend/template/autocomplete.phtml @@ -3,6 +3,9 @@ /** @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'); @@ -51,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); @@ -66,8 +69,8 @@ if ($config->isDefaultSelector()): ?> algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_que, label: '', name: "suggestions"}); } - algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: __('Categories')); ?>, name: "categories"}); - algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: __('Products')); ?>, name: "products"}); + algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_cat, label: escapeJsTranslatedString($this, 'Categories'); ?>, name: "categories"}); + algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: nb_pro, label: escapeJsTranslatedString($this, 'Products'); ?>, name: "products"}); /** Setup autocomplete data sources **/ var sources = [], @@ -102,7 +105,7 @@ if ($config->isDefaultSelector()): ?> }; if (algoliaConfig.removeBranding === false) { - options.templates.footer = ''; + options.templates.footer = ''; } /** Bind autocomplete feature to the input */ diff --git a/design/frontend/template/instantsearch.phtml b/design/frontend/template/instantsearch.phtml index 5fe9457b..de893189 100644 --- a/design/frontend/template/instantsearch.phtml +++ b/design/frontend/template/instantsearch.phtml @@ -1,3 +1,10 @@ + +