From caa819e9a16ede6b9851a57b5b820c93c34445f0 Mon Sep 17 00:00:00 2001
From: Jan Petr
Date: Mon, 18 Sep 2017 10:26:08 +0200
Subject: [PATCH 1/8] Change Magento Connect link to Magento Marketplace
---
js/algoliasearch/internals/adminhtml/admin_scripts.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/js/algoliasearch/internals/adminhtml/admin_scripts.js b/js/algoliasearch/internals/adminhtml/admin_scripts.js
index c9e51525..61b3b5ae 100644
--- a/js/algoliasearch/internals/adminhtml/admin_scripts.js
+++ b/js/algoliasearch/internals/adminhtml/admin_scripts.js
@@ -26,10 +26,10 @@ algoliaAdminBundle.$(function($) {
' You are using old version of Algolia extension. ' +
'Latest version of the extension is '+latestVersion+'. ' +
'You can get it on ' +
- 'Magento Connect. ' +
+ 'Magento Marketplace. ' +
'' +
'It\'s highly recommended to update your version to avoid any unexpecting issues and to get new features. ' +
- 'If you are happy with the extension, please rate the extension on Magento Connect.' +
+ 'If you are happy with the extension, please rate the extension on Magento Marketplace.' +
'');
}
});
From 279a356558dc48027be64e3b2ac4ced813c156c0 Mon Sep 17 00:00:00 2001
From: Jan Petr
Date: Wed, 20 Sep 2017 17:59:28 +0200
Subject: [PATCH 2/8] Fix docs links
---
app/code/community/Algolia/Algoliasearch/etc/system.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/community/Algolia/Algoliasearch/etc/system.xml b/app/code/community/Algolia/Algoliasearch/etc/system.xml
index fdeec604..32fc3b2e 100644
--- a/app/code/community/Algolia/Algoliasearch/etc/system.xml
+++ b/app/code/community/Algolia/Algoliasearch/etc/system.xml
@@ -939,7 +939,7 @@
@@ -975,7 +975,7 @@
Synonyms are defined by a comma-separated list of words that should be considered equivalent by the Algolia engine.
For instance: tv, television, tv set
Using that set, if a record contains “television” and a user searches for “TV”, this record will be returned.
- Documentation: https://www.algolia.com/doc/synonyms#synonyms
+ Documentation: https://www.algolia.com/doc/guides/textual-relevance/synonyms/#regular-synonyms
]]>
@@ -992,7 +992,7 @@
One-way synonyms allow you to define alternative words for a search term, which are not synonyms to each others.
Let’s take an example: when a user searches for “tablet”, you want him to be able to find iPads and Galaxy Note tablets alike, but you might not want Android tablets to show up when he searches for “iPad”.
To do this, you’d define a one-way synonyms set between tablet (as input) and ipad, galaxy note (as synonyms). When the user types in “tablet”, records containing “iPad” and “Galaxy Note” will be returned. However records containing only “tablet” or “Galaxy Note” won’t be returned if he searches for “iPad”.
- Documentation: https://www.algolia.com/doc/synonyms#one-way-synonyms
+ Documentation: https://www.algolia.com/doc/guides/textual-relevance/synonyms/#one-way-synonyms
Algolia offers more synonymys’ types - placeholders and alternative corrections. These types can be managed directly from your Algolia’s dashboard.
@@ -1153,7 +1153,7 @@
Example: {"exactOnSingleWordQuery":"word"}
⚠ Edit extra settings only when you're sure what you're doing. Bad settings can effect your search functionality and have a bad impact on your relevance.
]]>
From c49de470cc281c7c6d5382e05d8a676fee3a7ebc Mon Sep 17 00:00:00 2001
From: Jan Petr
Date: Thu, 21 Sep 2017 12:29:58 +0200
Subject: [PATCH 3/8] Configure the display of queue notification
---
.../Algoliasearch/Block/Adminhtml/Notifications.php | 8 ++++++++
.../community/Algolia/Algoliasearch/Helper/Config.php | 6 ++++++
app/code/community/Algolia/Algoliasearch/etc/config.xml | 1 +
app/code/community/Algolia/Algoliasearch/etc/system.xml | 9 +++++++++
.../default/template/algoliasearch/notifications.phtml | 4 ++++
5 files changed, 28 insertions(+)
diff --git a/app/code/community/Algolia/Algoliasearch/Block/Adminhtml/Notifications.php b/app/code/community/Algolia/Algoliasearch/Block/Adminhtml/Notifications.php
index b635372b..6e32391b 100644
--- a/app/code/community/Algolia/Algoliasearch/Block/Adminhtml/Notifications.php
+++ b/app/code/community/Algolia/Algoliasearch/Block/Adminhtml/Notifications.php
@@ -7,6 +7,14 @@ public function getConfigurationUrl()
return $this->getUrl('adminhtml/system_config/edit/section/algoliasearch');
}
+ public function showNotification()
+ {
+ /** @var Algolia_Algoliasearch_Helper_Config $config */
+ $config = Mage::helper('algoliasearch/config');
+
+ return $config->showQueueNotificiation();
+ }
+
public function getQueueInfo()
{
/** @var Algolia_Algoliasearch_Helper_Config $config */
diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Config.php b/app/code/community/Algolia/Algoliasearch/Helper/Config.php
index bffbe856..45b34fae 100644
--- a/app/code/community/Algolia/Algoliasearch/Helper/Config.php
+++ b/app/code/community/Algolia/Algoliasearch/Helper/Config.php
@@ -73,6 +73,7 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
const CUSTOMER_GROUPS_ENABLE = 'algoliasearch/advanced/customer_groups_enable';
const MAKE_SEO_REQUEST = 'algoliasearch/advanced/make_seo_request';
const REMOVE_BRANDING = 'algoliasearch/advanced/remove_branding';
+ const SHOW_QUEUE_NOTIFICATION = 'algoliasearch/advanced/show_queue_notification';
const AUTOCOMPLETE_SELECTOR = 'algoliasearch/advanced/autocomplete_selector';
const INDEX_PRODUCT_ON_CATEGORY_PRODUCTS_UPDATE = 'algoliasearch/advanced/index_product_on_category_products_update';
const INDEX_ALL_CATEGORY_PRODUCTS_ON_CATEGORY_UPDATE = 'algoliasearch/advanced/index_all_category_product_on_category_update';
@@ -244,6 +245,11 @@ public function isRemoveBranding($storeId = null)
return Mage::getStoreConfigFlag(self::REMOVE_BRANDING, $storeId);
}
+ public function showQueueNotificiation($storeId = null)
+ {
+ return Mage::getStoreConfigFlag(self::SHOW_QUEUE_NOTIFICATION, $storeId);
+ }
+
public function getMaxValuesPerFacet($storeId = null)
{
return Mage::getStoreConfig(self::MAX_VALUES_PER_FACET, $storeId);
diff --git a/app/code/community/Algolia/Algoliasearch/etc/config.xml b/app/code/community/Algolia/Algoliasearch/etc/config.xml
index ad193e48..e48aa3ac 100644
--- a/app/code/community/Algolia/Algoliasearch/etc/config.xml
+++ b/app/code/community/Algolia/Algoliasearch/etc/config.xml
@@ -246,6 +246,7 @@
010
+ 1.algolia-search-input10
diff --git a/app/code/community/Algolia/Algoliasearch/etc/system.xml b/app/code/community/Algolia/Algoliasearch/etc/system.xml
index fdeec604..d3a8ba1a 100644
--- a/app/code/community/Algolia/Algoliasearch/etc/system.xml
+++ b/app/code/community/Algolia/Algoliasearch/etc/system.xml
@@ -1093,6 +1093,15 @@
1Choose here if the algolia logo is added to the drop-down template.
+
+
+ select
+ adminhtml/system_config_source_yesno
+ 45
+ 1
+ 1
+ 1
+ text
diff --git a/app/design/adminhtml/default/default/template/algoliasearch/notifications.phtml b/app/design/adminhtml/default/default/template/algoliasearch/notifications.phtml
index a757f6ca..a8c56532 100644
--- a/app/design/adminhtml/default/default/template/algoliasearch/notifications.phtml
+++ b/app/design/adminhtml/default/default/template/algoliasearch/notifications.phtml
@@ -2,6 +2,10 @@
/** @var Algolia_Algoliasearch_Block_Adminhtml_Notifications $this */
+if ($this->showNotification() === false) {
+ return;
+}
+
$queueInfo = $this->getQueueInfo();
?>
From c29e7b82724346b925b20b78047936201134cb2b Mon Sep 17 00:00:00 2001
From: Jan Petr
Date: Thu, 21 Sep 2017 15:18:10 +0200
Subject: [PATCH 4/8] Refactored too big records detection
---
.../Algoliasearch/Helper/Algoliahelper.php | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Algoliahelper.php b/app/code/community/Algolia/Algoliasearch/Helper/Algoliahelper.php
index 81862825..06b71096 100644
--- a/app/code/community/Algolia/Algoliasearch/Helper/Algoliahelper.php
+++ b/app/code/community/Algolia/Algoliasearch/Helper/Algoliahelper.php
@@ -12,6 +12,12 @@ class Algolia_Algoliasearch_Helper_Algoliahelper extends Mage_Core_Helper_Abstra
/** @var Algolia_Algoliasearch_Helper_Config */
protected $config;
+ /** @var int */
+ protected $maxRecordSize = 20000;
+
+ /** @var array */
+ protected $potentiallyLongAttributes = array('description', 'short_description', 'meta_description', 'content');
+
/** @var string */
private $lastUsedIndexName;
@@ -287,18 +293,16 @@ private function prepareRecords(&$objects, $indexName)
if (!empty($modifiedIds)) {
/** @var Mage_Adminhtml_Model_Session $session */
$session = Mage::getSingleton('adminhtml/session');
- $session->addWarning('Algolia reindexing : You have some records ('.implode(',', $modifiedIds).') that are too big. They have either been truncated or skipped');
+ $session->addWarning('Algolia reindexing : You have some records ('.implode(',', $modifiedIds).') that are too big. They have either been truncated or skipped.');
}
}
public function handleTooBigRecord(&$object)
{
- $longAttributes = array('description', 'short_description', 'meta_description', 'content');
-
$size = mb_strlen(json_encode($object));
- if ($size > 20000) {
- foreach ($longAttributes as $attribute) {
+ if ($size > $this->maxRecordSize) {
+ foreach ($this->potentiallyLongAttributes as $attribute) {
if (isset($object[$attribute])) {
unset($object[$attribute]);
}
@@ -306,7 +310,7 @@ public function handleTooBigRecord(&$object)
$size = mb_strlen(json_encode($object));
- if ($size > 20000) {
+ if ($size > $this->maxRecordSize) {
$object = false;
}
}
From b4ee80b6a035a7e49ff37a3a19c2359011c32be6 Mon Sep 17 00:00:00 2001
From: Jan Petr
Date: Thu, 21 Sep 2017 16:19:11 +0200
Subject: [PATCH 5/8] Introduce event and attributes to always index/remove
product to/from Algolia
---
.../community/Algolia/Algoliasearch/Helper/Data.php | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Data.php b/app/code/community/Algolia/Algoliasearch/Helper/Data.php
index 8ffa3a16..cfb35145 100644
--- a/app/code/community/Algolia/Algoliasearch/Helper/Data.php
+++ b/app/code/community/Algolia/Algoliasearch/Helper/Data.php
@@ -476,6 +476,16 @@ protected function getProductsRecords($storeId, $collection, $potentiallyDeleted
unset($potentiallyDeletedProductsIds[$productId]);
}
+ Mage::dispatchEvent('algolia_before_product_availability_check', array('product' => $product, 'store' => $storeId));
+
+ if ($product->getData('algolia__noIndex') === true) {
+ $productsToRemove[$productId] = $productId;
+ }
+
+ if ($product->getData('algolia__alwaysIndex') === true) {
+ $productsToIndex[$productId] = $this->product_helper->getObject($product);
+ }
+
if (isset($productsToIndex[$productId]) || isset($productsToRemove[$productId])) {
continue;
}
@@ -489,8 +499,7 @@ protected function getProductsRecords($storeId, $collection, $potentiallyDeleted
continue;
}
- $productObject = $this->product_helper->getObject($product);
- $productsToIndex[$productId] = $productObject;
+ $productsToIndex[$productId] = $this->product_helper->getObject($product);
}
$productsToRemove = array_merge($productsToRemove, $potentiallyDeletedProductsIds);
From 3c5970404ddab5ce863277c1068d17c7bba4b443 Mon Sep 17 00:00:00 2001
From: Jan Petr
Date: Thu, 28 Sep 2017 11:29:23 +0200
Subject: [PATCH 6/8] Prevent backend rendering (#886)
---
.../Algolia/Algoliasearch/Helper/Config.php | 31 +++++++++++++++++++
.../Algolia/Algoliasearch/Model/Observer.php | 4 +++
.../Algolia/Algoliasearch/etc/config.xml | 3 ++
.../Algolia/Algoliasearch/etc/system.xml | 30 ++++++++++++++++++
.../base/default/layout/algoliasearch.xml | 22 +++++++++++++
5 files changed, 90 insertions(+)
diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Config.php b/app/code/community/Algolia/Algoliasearch/Helper/Config.php
index 45b34fae..fc0d33bf 100644
--- a/app/code/community/Algolia/Algoliasearch/Helper/Config.php
+++ b/app/code/community/Algolia/Algoliasearch/Helper/Config.php
@@ -77,6 +77,8 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
const AUTOCOMPLETE_SELECTOR = 'algoliasearch/advanced/autocomplete_selector';
const INDEX_PRODUCT_ON_CATEGORY_PRODUCTS_UPDATE = 'algoliasearch/advanced/index_product_on_category_products_update';
const INDEX_ALL_CATEGORY_PRODUCTS_ON_CATEGORY_UPDATE = 'algoliasearch/advanced/index_all_category_product_on_category_update';
+ const PREVENT_BACKEND_RENDERING = 'algoliasearch/advanced/prevent_backend_rendering';
+ const BACKEND_RENDERING_ALLOWED_USER_AGENTS = 'algoliasearch/advanced/backend_rendering_allowed_user_agents';
const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock';
const LOGGING_ENABLED = 'algoliasearch/credentials/debug';
@@ -639,6 +641,35 @@ public function getExtraSettings($section, $storeId = null)
return trim(Mage::getStoreConfig(constant('self::'.$constant), $storeId));
}
+ public function preventBackendRendering($storeId = null)
+ {
+ $preventBackendRendering = Mage::getStoreConfigFlag(self::PREVENT_BACKEND_RENDERING, $storeId);
+
+ if ($preventBackendRendering === false) {
+ return false;
+ }
+
+ $userAgent = mb_strtolower($_SERVER['HTTP_USER_AGENT'], 'utf-8');
+
+ $allowedUserAgents = Mage::getStoreConfig(self::BACKEND_RENDERING_ALLOWED_USER_AGENTS, $storeId);
+ $allowedUserAgents = trim($allowedUserAgents);
+
+ if ($allowedUserAgents === '') {
+ return true;
+ }
+
+ $allowedUserAgents = explode("\n", $allowedUserAgents);
+
+ foreach ($allowedUserAgents as $allowedUserAgent) {
+ $allowedUserAgent = mb_strtolower($allowedUserAgent, 'utf-8');
+ if (strpos($userAgent, $allowedUserAgent) !== false) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
private function getCustomRanking($configName, $storeId = null)
{
$attrs = unserialize(Mage::getStoreConfig($configName, $storeId));
diff --git a/app/code/community/Algolia/Algoliasearch/Model/Observer.php b/app/code/community/Algolia/Algoliasearch/Model/Observer.php
index f52a62ae..06c7ab06 100644
--- a/app/code/community/Algolia/Algoliasearch/Model/Observer.php
+++ b/app/code/community/Algolia/Algoliasearch/Model/Observer.php
@@ -76,6 +76,10 @@ public function useAlgoliaSearchPopup(Varien_Event_Observer $observer)
} else {
$observer->getLayout()->getUpdate()->addHandle('algolia_search_handle_no_topsearch');
}
+
+ if ($this->config->preventBackendRendering() === true) {
+ $observer->getLayout()->getUpdate()->addHandle('algolia_search_handle_prevent_backend_rendering');
+ }
}
}
}
diff --git a/app/code/community/Algolia/Algoliasearch/etc/config.xml b/app/code/community/Algolia/Algoliasearch/etc/config.xml
index e48aa3ac..386d5291 100644
--- a/app/code/community/Algolia/Algoliasearch/etc/config.xml
+++ b/app/code/community/Algolia/Algoliasearch/etc/config.xml
@@ -250,6 +250,9 @@
.algolia-search-input10
+ 0
+ Googlebot
+Bingbot