diff --git a/Block/Configuration.php b/Block/Configuration.php index 87f7788e5..6c5c871a6 100755 --- a/Block/Configuration.php +++ b/Block/Configuration.php @@ -309,6 +309,7 @@ public function getConfiguration() 'relevance' => __('Relevance'), 'categories' => __('Categories'), 'products' => __('Products'), + 'suggestions' => __('Suggestions'), 'searchBy' => __('Search by'), 'searchForFacetValuesPlaceholder' => __('Search for other ...'), 'showMore' => __('Show more products'), diff --git a/CHANGELOG.md b/CHANGELOG.md index f20aa0136..5c4dce0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # CHANGE LOG +## 3.10.1 + +### UPDATES +- Added recommended js version in readme file. + +### Bug Fixes +- Add caching on category name lookup (scoped by store) to fix slowness in indexing. +- Prevent loss of synonyms while copying from tmp index during Indexing in Algolia Dashboard. +- Fixed the translation issue of labels in Algolia autocomplete dropdown +- Ensured compatibility of the extension with PHP 7.4 +- Resolved the deployment issue related to prefixing Magento database tables + ## 3.10.0 diff --git a/Helper/Entity/CategoryHelper.php b/Helper/Entity/CategoryHelper.php index a31209153..264ad71b9 100755 --- a/Helper/Entity/CategoryHelper.php +++ b/Helper/Entity/CategoryHelper.php @@ -50,6 +50,7 @@ class CategoryHelper protected $categoryRepository; protected $isCategoryVisibleInMenuCache; + protected $coreCategories; protected $idColumn; protected $categoryAttributes; protected $rootCategoryId = -1; @@ -548,7 +549,12 @@ public function isCategoryVisibleInMenu($categoryId, $storeId) */ public function getCoreCategories($filterNotIncludedCategories = true, $storeId = null) { - $key = $filterNotIncludedCategories ? 'filtered' : 'non_filtered'; + // Cache category look up by store scope + $key = ($filterNotIncludedCategories ? 'filtered' : 'non_filtered') . "-$storeId"; + + if (isset($this->coreCategories[$key])) { + return $this->coreCategories[$key]; + } $collection = $this->categoryCollectionFactory->create() ->distinct(true) @@ -562,14 +568,14 @@ public function getCoreCategories($filterNotIncludedCategories = true, $storeId $collection->addAttributeToFilter('include_in_menu', '1'); } - $coreCategories[$key] = []; + $this->coreCategories[$key] = []; /** @var \Magento\Catalog\Model\Category $category */ foreach ($collection as $category) { - $coreCategories[$key][$category->getId()] = $category; + $this->coreCategories[$key][$category->getId()] = $category; } - return $coreCategories[$key]; + return $this->coreCategories[$key]; } /** diff --git a/Helper/Entity/ProductHelper.php b/Helper/Entity/ProductHelper.php index 570c6c011..814f8805a 100755 --- a/Helper/Entity/ProductHelper.php +++ b/Helper/Entity/ProductHelper.php @@ -485,8 +485,8 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic } else { foreach ($sortingIndices as $values) { $replicaName = $values['name']; - array_unshift($customRanking,$values['ranking'][0]); - $replicaSetting['customRanking'] = $customRanking; + array_unshift($customRanking,$values['ranking'][0]); + $replicaSetting['customRanking'] = $customRanking; $this->algoliaHelper->setSettings($replicaName, $replicaSetting, false, false); $this->logger->log('Setting settings to "' . $replicaName . '" replica.'); $this->logger->log('Settings: ' . json_encode($replicaSetting)); @@ -502,6 +502,15 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic // $this->deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId); if ($saveToTmpIndicesToo === true) { + try { + $this->algoliaHelper->copySynonyms($indexName, $indexNameTmp); + $this->logger->log(' + Copying synonyms from production index to TMP one to not erase them with the index move. + '); + } catch (AlgoliaException $e) { + $this->logger->error('Error encountered while copying synonyms: ' . $e->getMessage()); + } + try { $this->algoliaHelper->copyQueryRules($indexName, $indexNameTmp); $this->logger->log(' diff --git a/Observer/Insights/CheckoutCartProductAddAfter.php b/Observer/Insights/CheckoutCartProductAddAfter.php index cc8bbda68..422db32ae 100644 --- a/Observer/Insights/CheckoutCartProductAddAfter.php +++ b/Observer/Insights/CheckoutCartProductAddAfter.php @@ -18,22 +18,22 @@ class CheckoutCartProductAddAfter implements ObserverInterface { /** @var Data */ - protected Data $dataHelper; + protected $dataHelper; /** @var InsightsHelper */ - protected InsightsHelper $insightsHelper; + protected $insightsHelper; /** @var LoggerInterface */ - protected LoggerInterface $logger; + protected $logger; /** @var ConfigHelper */ - protected ConfigHelper $configHelper; + protected $configHelper; /** @var PersonalizationHelper */ - private PersonalizationHelper $personalizationHelper; + protected $personalizationHelper; /** @var SessionManagerInterface */ - protected SessionManagerInterface $coreSession; + protected $coreSession; /** * @param Data $dataHelper diff --git a/Observer/Insights/CheckoutCartProductAddBefore.php b/Observer/Insights/CheckoutCartProductAddBefore.php index b9034b430..8937998e0 100644 --- a/Observer/Insights/CheckoutCartProductAddBefore.php +++ b/Observer/Insights/CheckoutCartProductAddBefore.php @@ -9,7 +9,7 @@ class CheckoutCartProductAddBefore implements ObserverInterface { /** @var SessionManagerInterface */ - protected SessionManagerInterface $coreSession; + protected $coreSession; /** * @param SessionManagerInterface $coreSession diff --git a/Observer/Insights/CheckoutOnepageControllerSuccessAction.php b/Observer/Insights/CheckoutOnepageControllerSuccessAction.php index c688fed95..885a061fd 100644 --- a/Observer/Insights/CheckoutOnepageControllerSuccessAction.php +++ b/Observer/Insights/CheckoutOnepageControllerSuccessAction.php @@ -16,19 +16,19 @@ class CheckoutOnepageControllerSuccessAction implements ObserverInterface { /** @var Data */ - protected Data $dataHelper; + protected $dataHelper; /** @var InsightsHelper */ - protected InsightsHelper $insightsHelper; + protected $insightsHelper; /** @var OrderFactory */ - protected OrderFactory $orderFactory; + protected $orderFactory; /** @var LoggerInterface */ - protected LoggerInterface $logger; + protected $logger; /** @var ConfigHelper */ - protected ConfigHelper $configHelper; + protected $configHelper; /** * @param Data $dataHelper diff --git a/Observer/Insights/CustomerLogin.php b/Observer/Insights/CustomerLogin.php index 81e65e6e9..145cd0b5b 100644 --- a/Observer/Insights/CustomerLogin.php +++ b/Observer/Insights/CustomerLogin.php @@ -11,7 +11,7 @@ class CustomerLogin implements ObserverInterface { /** @var InsightsHelper */ - protected InsightsHelper $insightsHelper; + protected $insightsHelper; /** * @param InsightsHelper $insightsHelper diff --git a/Observer/Insights/WishlistProductAddAfter.php b/Observer/Insights/WishlistProductAddAfter.php index 1dc53ba62..ed4b5add8 100644 --- a/Observer/Insights/WishlistProductAddAfter.php +++ b/Observer/Insights/WishlistProductAddAfter.php @@ -15,16 +15,16 @@ class WishlistProductAddAfter implements ObserverInterface { /** @var Data */ - protected Data $dataHelper; + protected $dataHelper; /** @var PersonalizationHelper */ - protected PersonalizationHelper $personalisationHelper; + protected $personalisationHelper; /** @var InsightsHelper */ - protected InsightsHelper $insightsHelper; + protected $insightsHelper; /** @var LoggerInterface */ - protected LoggerInterface $logger; + protected $logger; /** * CheckoutCartProductAddAfter constructor. diff --git a/README.md b/README.md index 177b33f3b..7117a6888 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Algolia Search for Magento 2 ================== -![Latest version](https://img.shields.io/badge/latest-3.10.0-green) +![Latest version](https://img.shields.io/badge/latest-3.10.1-green) ![Magento 2](https://img.shields.io/badge/Magento-2.4.x-orange) ![PHP](https://img.shields.io/badge/PHP-8.1,7.4-blue) @@ -89,12 +89,13 @@ These libraries are here to help add to your customisation but because the exten #### The Extension JS Bundle Knowing the version of the library will help you understand what is available in these libraries for you to leverage in terms of customisation. This table will help you determine which documentation to reference when you start working on your customisation. -| Extension Version | autocomplete.js | instantsearch.js | search-insights.js | -|-------------------|-------------------------------------------------------------------| --- | --- | -| v1.x | [0.26.0](https://github.com/algolia/autocomplete.js/tree/v0.26.0) | [2.10.2](https://github.com/algolia/instantsearch.js/tree/v2.10.2) | [0.0.14](https://cdn.jsdelivr.net/npm/search-insights@0.0.14) | -| v2.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.7.2](https://github.com/algolia/instantsearch.js/tree/v4.7.2) | [1.4.0](https://github.com/algolia/search-insights.js/tree/v1.4.0) | -| v3.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.15.0](https://github.com/algolia/instantsearch.js/tree/v4.15.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | -| v3.8.x | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | +| Extension Version | autocomplete.js | instantsearch.js | search-insights.js | recommend.js | +|-------------------|-------------------------------------------------------------------| --- | --- | --- | +| v1.x | [0.26.0](https://github.com/algolia/autocomplete.js/tree/v0.26.0) | [2.10.2](https://github.com/algolia/instantsearch.js/tree/v2.10.2) | [0.0.14](https://cdn.jsdelivr.net/npm/search-insights@0.0.14) | NA | +| v2.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.7.2](https://github.com/algolia/instantsearch.js/tree/v4.7.2) | [1.4.0](https://github.com/algolia/search-insights.js/tree/v1.4.0) | NA | +| v3.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.15.0](https://github.com/algolia/instantsearch.js/tree/v4.15.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | NA | +| v3.9.1 | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | [1.5.0](https://github.com/algolia/recommend/tree/v1.5.0) | +| v3.10.x | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | [1.8.0](https://github.com/algolia/recommend/tree/v1.8.0) | The autocomplete and instantsearch libraries are accessible in the `algoliaBundle` global. This bundle is a prepackage javascript file that contains it's dependencies. What is included in this bundle can be seen here: diff --git a/Setup/Patch/Schema/AutocompleteConfigPatch.php b/Setup/Patch/Schema/AutocompleteConfigPatch.php index e7896f42e..cc879e439 100644 --- a/Setup/Patch/Schema/AutocompleteConfigPatch.php +++ b/Setup/Patch/Schema/AutocompleteConfigPatch.php @@ -37,7 +37,7 @@ public function apply() ]; $this->moduleDataSetup->getConnection()->startSetup(); $connection = $this->moduleDataSetup->getConnection(); - $table = $connection->getTableName('core_config_data'); + $table = $this->moduleDataSetup->getTable('core_config_data'); foreach ($movedConfigDirectives as $from => $to) { try { $connection->query('UPDATE ' . $table . ' SET path = "' . $to . '" WHERE path = "' . $from . '"'); diff --git a/composer.json b/composer.json index 1afd38731..1ab8d835d 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Algolia Search integration for Magento 2", "type": "magento2-module", "license": ["MIT"], - "version": "3.10.0", + "version": "3.10.1", "require": { "magento/framework": "~102.0|~103.0", "algolia/algoliasearch-client-php": "3.2", diff --git a/etc/module.xml b/etc/module.xml index 4409cf090..395312434 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index 3e7be88fb..f6a6594ac 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -327,7 +327,7 @@ define( } if (algoliaConfig.autocomplete.nbOfQueriesSuggestions > 0) { - algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: algoliaConfig.autocomplete.nbOfQueriesSuggestions, label: '', name: "suggestions"}); + algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: algoliaConfig.autocomplete.nbOfQueriesSuggestions, label: algoliaConfig.translations.suggestions, name: "suggestions"}); } /** diff --git a/view/frontend/web/internals/template/autocomplete/additional-section.js b/view/frontend/web/internals/template/autocomplete/additional-section.js index 354c9f2d7..2f8f09c53 100644 --- a/view/frontend/web/internals/template/autocomplete/additional-section.js +++ b/view/frontend/web/internals/template/autocomplete/additional-section.js @@ -1,7 +1,7 @@ define([], function () { return { getNoResultHtml: function ({html}) { - return html`

No Results

`; + return html`

${algoliaConfig.translations.noResults}

`; }, getHeaderHtml: function ({section}) { diff --git a/view/frontend/web/internals/template/autocomplete/categories.js b/view/frontend/web/internals/template/autocomplete/categories.js index 7806ab35f..166e84a68 100644 --- a/view/frontend/web/internals/template/autocomplete/categories.js +++ b/view/frontend/web/internals/template/autocomplete/categories.js @@ -1,11 +1,11 @@ define([], function () { return { getNoResultHtml: function ({html}) { - return html`

No Results

`; + return html`

${algoliaConfig.translations.noResults}

`; }, getHeaderHtml: function ({section}) { - return section.name; + return section.label; }, getItemHtml: function ({item, components, html}) { diff --git a/view/frontend/web/internals/template/autocomplete/pages.js b/view/frontend/web/internals/template/autocomplete/pages.js index b63e05047..3a6f91ee6 100644 --- a/view/frontend/web/internals/template/autocomplete/pages.js +++ b/view/frontend/web/internals/template/autocomplete/pages.js @@ -1,11 +1,11 @@ define([], function () { return { getNoResultHtml: function ({html}) { - return html`

No Results

`; + return html`

${algoliaConfig.translations.noResults}

`; }, getHeaderHtml: function ({section}) { - return section.label || section.name; + return section.label; }, getItemHtml: function ({item, components, html}) { diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index e673d10ee..7f55d1b3a 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -6,7 +6,7 @@ define([], function () { //////////////////// getNoResultHtml: function ({html}) { - return html`

No Results

`; + return html`

${algoliaConfig.translations.noResults}

`; }, getHeaderHtml: function () { diff --git a/view/frontend/web/internals/template/autocomplete/suggestions.js b/view/frontend/web/internals/template/autocomplete/suggestions.js index 496bd5b27..10bf5cfdb 100644 --- a/view/frontend/web/internals/template/autocomplete/suggestions.js +++ b/view/frontend/web/internals/template/autocomplete/suggestions.js @@ -1,11 +1,11 @@ define([], function () { return { getNoResultHtml: function ({html}) { - return html`

No Results

`; + return html`

${algoliaConfig.translations.noResults}

`; }, getHeaderHtml: function ({section}) { - return section.name; + return section.label; }, getItemHtml: function ({item, html}) {