diff --git a/CHANGELOG.md b/CHANGELOG.md index e8e6e02c..d67597e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ ## CHANGE LOG +### 1.12.0 + +Since this release, the extension is **Enterprise Edition compliant**! + +## FEATURES +- Experimental feature to prevent backend rendering of category and search results pages (#886) + - Use very carefully and read [documentation](https://community.algolia.com/magento/doc/m1/prevent-backend-rendering/) before enabling it +- Introduced events and developer attributes to force add / remove product(s) to / from Algolia (#922) +- Added to option to turn off administration top bar with information about queue (#920) + +## UPDATES +- Changed some links in the configuration + +## FIXES +- Fixed failing database migration for creation of queue log table (#927) + ### 1.11.1 - Query rules are preserved during reindex with indexing queue enabled (#913) diff --git a/README.md b/README.md index d1e25c0c..6d770cd7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Algolia Search for Magento 1.6+ ================== -![Latest version](https://img.shields.io/badge/latest-1.11.1-green.svg) +![Latest version](https://img.shields.io/badge/latest-1.12.0-green.svg) [![Build Status](https://travis-ci.org/algolia/algoliasearch-magento.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-magento) ![PHP >= 5.3](https://img.shields.io/badge/php-%3E=5.3-green.svg) 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/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; } } diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Config.php b/app/code/community/Algolia/Algoliasearch/Helper/Config.php index bffbe856..fc0d33bf 100644 --- a/app/code/community/Algolia/Algoliasearch/Helper/Config.php +++ b/app/code/community/Algolia/Algoliasearch/Helper/Config.php @@ -73,9 +73,12 @@ 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'; + 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'; @@ -244,6 +247,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); @@ -633,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/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); 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 ad193e48..a53321dd 100644 --- a/app/code/community/Algolia/Algoliasearch/etc/config.xml +++ b/app/code/community/Algolia/Algoliasearch/etc/config.xml @@ -2,7 +2,7 @@ - 1.11.1 + 1.12.0 @@ -246,9 +246,13 @@ 0 1 0 + 1 .algolia-search-input 1 0 + 0 + Googlebot +Bingbot