Skip to content

Commit

Permalink
Develop 1.x (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
damcou authored Sep 29, 2020
1 parent d0ccc1d commit 1a5e04f
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 33 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Helper/AlgoliaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);

Expand Down
12 changes: 7 additions & 5 deletions Helper/Entity/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
26 changes: 19 additions & 7 deletions Helper/MerchandisingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,35 @@ 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,
],
];

if (!is_null($query) && $query != '') {
$rule['condition']['pattern'] = $query;
$condition['pattern'] = $query;
}

if (! is_null($banner)) {
$rule['consequence']['userData']['banner'] = $banner;
}

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);
Expand Down Expand Up @@ -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;
}

Expand Down
15 changes: 1 addition & 14 deletions Model/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Algolia\AlgoliaSearch\Model;

use Algolia\AlgoliaSearch\Api\Data\JobInterface;
use Magento\Framework\DataObject\IdentityInterface;

/**
* @api
Expand All @@ -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 */
Expand Down Expand Up @@ -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
*/
Expand Down
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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.
Expand Down Expand Up @@ -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/[email protected]) |
| 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:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
{
Expand Down
4 changes: 2 additions & 2 deletions etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::system">
<resource id="Algolia_AlgoliaSearch::manage" title="Algolia Search" sortOrder="99999" />
<resource id="Algolia_AlgoliaSearch::manage" title="Algolia Search" translate="title" sortOrder="99999" />
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Algolia_AlgoliaSearch::algolia_algoliasearch" title="Algolia Search"/>
<resource id="Algolia_AlgoliaSearch::algolia_algoliasearch" title="Algolia Search" translate="title"/>
</resource>
</resource>
</resource>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Algolia_AlgoliaSearch" setup_version="1.13.2">
<module name="Algolia_AlgoliaSearch" setup_version="1.13.3">
<sequence>
<module name="Magento_Theme"/>
<module name="Magento_Backend"/>
Expand Down

0 comments on commit 1a5e04f

Please sign in to comment.