From 1a5e04fe72fa9fd4d1b1aedc311d08ff0ce8590b Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Tue, 29 Sep 2020 13:29:54 +0200 Subject: [PATCH] Develop 1.x (#1090) --- CHANGELOG.md | 9 +++++ Helper/AlgoliaHelper.php | 2 +- Helper/Entity/ProductHelper.php | 12 ++++--- Helper/MerchandisingHelper.php | 26 +++++++++++---- Model/Job.php | 15 +-------- README.md | 59 ++++++++++++++++++++++++++++++++- composer.json | 5 +-- etc/acl.xml | 4 +-- etc/module.xml | 2 +- 9 files changed, 101 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec21bcc44..eab8906fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # CHANGE LOG +## 1.13.3 + +### UPDATES +- Set forwardToReplicas for copy rules to false (#1060) +- Added algolia/algoliasearch-inventory-magento-2 to suggested modules by Composer (#1040) @vmalyk +- Set ACL resource titles are translatable. (#1076) @vmalyk +- Change condition to accept multi conditions (#1087) +- Remove IdentityInterface from job model class (#1088) + ## 1.13.2 ### UPDATES diff --git a/Helper/AlgoliaHelper.php b/Helper/AlgoliaHelper.php index 18bcc11e7..eddd6bd69 100755 --- a/Helper/AlgoliaHelper.php +++ b/Helper/AlgoliaHelper.php @@ -355,7 +355,7 @@ public function copySynonyms($fromIndexName, $toIndexName) public function copyQueryRules($fromIndexName, $toIndexName) { $res = $this->getClient()->scopedCopyIndex($fromIndexName, $toIndexName, ['rules'], [ - 'forwardToReplicas' => true, + 'forwardToReplicas' => false, 'clearExistingRules' => true, ]); diff --git a/Helper/Entity/ProductHelper.php b/Helper/Entity/ProductHelper.php index dd27c058f..9161d1092 100755 --- a/Helper/Entity/ProductHelper.php +++ b/Helper/Entity/ProductHelper.php @@ -1048,14 +1048,16 @@ private function setFacetsQueryRules($indexName) $attribute = $facet['attribute']; + $condition = [ + 'anchoring' => 'contains', + 'pattern' => '{facet:' . $attribute . '}', + 'context' => 'magento_filters', + ]; + $rules[] = [ 'objectID' => 'filter_' . $attribute, 'description' => 'Filter facet "' . $attribute . '"', - 'condition' => [ - 'anchoring' => 'contains', - 'pattern' => '{facet:' . $attribute . '}', - 'context' => 'magento_filters', - ], + 'conditions' => [$condition], 'consequence' => [ 'params' => [ 'automaticFacetFilters' => [$attribute], diff --git a/Helper/MerchandisingHelper.php b/Helper/MerchandisingHelper.php index a097c576e..09ca9036f 100755 --- a/Helper/MerchandisingHelper.php +++ b/Helper/MerchandisingHelper.php @@ -36,14 +36,15 @@ public function saveQueryRule($storeId, $entityId, $rawPositions, $entityType, $ $positions = $this->transformPositions($rawPositions); + $condition = [ + 'pattern' => '', + 'anchoring' => 'is', + 'context' => 'magento-' . $entityType . '-' . $entityId, + ]; + $rule = [ 'objectID' => $this->getQueryRuleId($entityId, $entityType), 'description' => 'MagentoGeneratedQueryRule', - 'condition' => [ - 'pattern' => '', - 'anchoring' => 'is', - 'context' => 'magento-' . $entityType . '-' . $entityId, - ], 'consequence' => [ 'filterPromotes' => true, 'promote' => $positions, @@ -51,7 +52,7 @@ public function saveQueryRule($storeId, $entityId, $rawPositions, $entityType, $ ]; if (!is_null($query) && $query != '') { - $rule['condition']['pattern'] = $query; + $condition['pattern'] = $query; } if (! is_null($banner)) { @@ -59,9 +60,11 @@ public function saveQueryRule($storeId, $entityId, $rawPositions, $entityType, $ } if ($entityType == 'query') { - unset($rule['condition']['context']); + unset($condition['context']); } + $rule['conditions'] = [$condition]; + // Not catching AlgoliaSearchException for disabled query rules on purpose // It displays correct error message and navigates user to pricing page $this->algoliaHelper->saveRule($rule, $productsIndexName); @@ -131,6 +134,15 @@ public function copyQueryRules($storeId, $entityIdFrom, $entityIdTo, $entityType if (isset($hit['condition']['context']) && $hit['condition']['context'] == $context) { $hit['condition']['context'] = $newContext; } + + if (isset($hit['conditions']) && is_array($hit['conditions'])) { + foreach ($hit['conditions'] as &$condition) { + if (isset($condition['context']) && $condition['context'] == $context) { + $condition['context'] = $newContext; + } + } + } + $queryRulesToSet[] = $hit; } diff --git a/Model/Job.php b/Model/Job.php index c2a612ce8..f2edb99ea 100644 --- a/Model/Job.php +++ b/Model/Job.php @@ -3,7 +3,6 @@ namespace Algolia\AlgoliaSearch\Model; use Algolia\AlgoliaSearch\Api\Data\JobInterface; -use Magento\Framework\DataObject\IdentityInterface; /** * @api @@ -25,12 +24,8 @@ * @method $this setDecodedData($decodedData) * @method $this setMergedIds($mergedIds) */ -class Job extends \Magento\Framework\Model\AbstractModel implements IdentityInterface, JobInterface +class Job extends \Magento\Framework\Model\AbstractModel implements JobInterface { - const CACHE_TAG = 'algoliasearch_queue_job'; - - protected $_cacheTag = 'algoliasearch_queue_job'; - protected $_eventPrefix = 'algoliasearch_queue_job'; /** @var \Magento\Framework\ObjectManagerInterface */ @@ -197,14 +192,6 @@ public function merge(Job $mergedJob) return $this; } - /** - * @return array|string[] - */ - public function getIdentities() - { - return [self::CACHE_TAG . '_' . $this->getId()]; - } - /** * @return array */ diff --git a/README.md b/README.md index 335ebfd59..0f78ac76f 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Algolia Search for Magento 2 ================== -![Latest version](https://img.shields.io/badge/latest-1.13.2-green.svg) +![Latest version](https://img.shields.io/badge/latest-1.13.3-green.svg) ![Magento 2](https://img.shields.io/badge/Magento-%3E=2.2%20<2.4-blue.svg) ![PHP >= 7.0.6](https://img.shields.io/badge/PHP-%3E=7.0-green.svg) @@ -13,6 +13,20 @@ Algolia Search for Magento 2 ------- +#### Magento 2.4 compatibility & extension's versions End of Life + +We are happy to announce that the version 3.x of our extension is now compatible with Magento 2.4. Review the [Customisation](https://github.com/algolia/algoliasearch-magento-2#customisation) section to learn more about the differences between our extension versions. + +Additionally, we are announcing the end of life for our legacy versions. We will continue to support and backport major changes to the minor branches until the defined dates below. We will not accept community PRs for those branches after this date. + +| Extension Version | End of Life | +| --- | --- | +| v1.x | Dec 2020 | +| v2.x | Dec 2020 | +| v3.x | N/A | + +------- + - **Autocompletion menu:** Offer End-Users immediate access to your whole catalog from the dropdown menu, whatever your number of categories or attributes. - **Instantsearch results page:** Have your search results page, navigation and pagination updated in realtime, after each keystroke. @@ -55,6 +69,49 @@ Contribution To start contributing to the extension follow the [contributing guildelines](.github/CONTRIBUTING.md). +Customisation +------------ +The extension uses libraries to help assist with the frontend implementation for autocomplete, instantsearch, and insight features. It also uses the Algolia PHP client to leverage indexing and search methods from the backend. When you approach customisations for either, you have to understand that you are customising the implementation itself and not the components it is based on. + +These libraries are here to help add to your customisation but because the extension has already initialised these components, you should hook into the area between the extension the libraries. + +#### 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.26.0](https://github.com/algolia/autocomplete.js/tree/v0.26.0) | [4.0.0](https://github.com/algolia/instantsearch.js/tree/v4.0.0) | [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.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) | + +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: + +v1.x latest bundle: https://github.com/algolia/algoliasearch-extensions-bundle/blob/ISv2/package.json \ +v2.x latest bundle: https://github.com/algolia/algoliasearch-extensions-bundle/blob/ISv4/package.json + +The search-insights.js library is standalone. + +Refer to these docs when customising your Algolia Magento extension frontend features: + - [Autocomplete](https://www.algolia.com/doc/integration/magento-2/customize/autocomplete-menu/) + - [Instantsearch](https://www.algolia.com/doc/integration/magento-2/customize/instant-search-page/) + - [Frontend Custom Events](https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/) + + +#### The Algolia PHP API Client +The extension does most of the heavy lifting when it comes to gathering and preparing the data needed for indexing to Algolia. In terms of interacting with the Algolia Search API, the extension leverages the PHP API Client for backend methods including indexing, configuration, and search queries. + +Depending on the extension version you are using, you could have a different PHP API client version powering the extension's backend functionality. + +| Extension Version | API Client Version | +| --- | --- | +| v1.x | [1.28.0](https://github.com/algolia/algoliasearch-client-php/tree/1.28.0) | +| v2.x | [2.5.1](https://github.com/algolia/algoliasearch-client-php/tree/2.5.1) | +| v3.x | [2.5.1](https://github.com/algolia/algoliasearch-client-php/tree/2.5.1) | + +Refer to these docs when customising your Algolia Magento extension backend: +- [Indexing](https://www.algolia.com/doc/integration/magento-2/how-it-works/indexing/) +- [Dispatched Backend Events](https://www.algolia.com/doc/integration/magento-2/customize/custom-back-end-events/) + Need Help? ------------ Here are some helpful documentation to help with your issue: diff --git a/composer.json b/composer.json index 47ee0ece7..edc047add 100755 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Algolia Search integration for Magento 2", "type": "magento2-module", "license": ["MIT"], - "version": "1.13.2", + "version": "1.13.3", "require": { "php": "~7.0|~7.1|~7.2|~7.3", "magento/framework": "~101.0|~102.0", @@ -15,7 +15,8 @@ "ext-dom": "*" }, "suggest": { - "algolia/algoliasearch-magento-2-es-compatibility": "Algolia Search ES Compatibility module for Magento >=2.3.1|>=2.2.8" + "algolia/algoliasearch-magento-2-es-compatibility": "Algolia Search ES Compatibility module for Magento >=2.3.1|>=2.2.8", + "algolia/algoliasearch-inventory-magento-2": "Algolia Search Inventory module for Magento 2.3.x and Algolia Search 1.12+ extension" }, "repositories": [ { diff --git a/etc/acl.xml b/etc/acl.xml index 2192aaf94..80b348f0c 100644 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -4,12 +4,12 @@ - + - + diff --git a/etc/module.xml b/etc/module.xml index 783ebf8ee..338d4de80 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +