Skip to content

Commit 59c1602

Browse files
authored
Merge pull request #1282 from algolia/update/MAGE-373
Deprecated the Synonyms settings from the magento dashboard
2 parents 2c28324 + 5e403d0 commit 59c1602

File tree

7 files changed

+3
-289
lines changed

7 files changed

+3
-289
lines changed

Helper/ConfigHelper.php

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class ConfigHelper
6262
public const XML_PATH_IMAGE_HEIGHT = 'algoliasearch_images/image/height';
6363
public const XML_PATH_IMAGE_TYPE = 'algoliasearch_images/image/type';
6464

65-
public const ENABLE_SYNONYMS = 'algoliasearch_synonyms/synonyms_group/enable_synonyms';
66-
public const SYNONYMS = 'algoliasearch_synonyms/synonyms_group/synonyms';
67-
public const ONEWAY_SYNONYMS = 'algoliasearch_synonyms/synonyms_group/oneway_synonyms';
68-
public const SYNONYMS_FILE = 'algoliasearch_synonyms/synonyms_group/synonyms_file';
69-
7065
public const CC_ANALYTICS_ENABLE = 'algoliasearch_cc_analytics/cc_analytics_group/enable';
7166
public const CC_ANALYTICS_IS_SELECTOR = 'algoliasearch_cc_analytics/cc_analytics_group/is_selector';
7267
public const CC_CONVERSION_ANALYTICS_MODE = 'algoliasearch_cc_analytics/cc_analytics_group/conversion_analytics_mode';
@@ -1454,64 +1449,6 @@ public function getAttributesToFilter($groupId)
14541449
return count($attributes) ? ['filters' => implode(' AND ', $attributes)] : [];
14551450
}
14561451

1457-
/**
1458-
* @param $storeId
1459-
* @return bool
1460-
*/
1461-
public function isEnabledSynonyms($storeId = null)
1462-
{
1463-
return $this->configInterface->isSetFlag(self::ENABLE_SYNONYMS, ScopeInterface::SCOPE_STORE, $storeId);
1464-
}
1465-
1466-
/**
1467-
* @param $storeId
1468-
* @return array
1469-
*/
1470-
public function getSynonyms($storeId = null)
1471-
{
1472-
$synonyms = $this->unserialize($this->configInterface->getValue(
1473-
self::SYNONYMS,
1474-
ScopeInterface::SCOPE_STORE,
1475-
$storeId
1476-
));
1477-
if (is_array($synonyms)) {
1478-
return $synonyms;
1479-
}
1480-
return [];
1481-
}
1482-
1483-
/**
1484-
* @param $storeId
1485-
* @return array
1486-
*/
1487-
public function getOnewaySynonyms($storeId = null)
1488-
{
1489-
$onewaySynonyms = $this->unserialize($this->configInterface->getValue(
1490-
self::ONEWAY_SYNONYMS,
1491-
ScopeInterface::SCOPE_STORE,
1492-
$storeId
1493-
));
1494-
if (is_array($onewaySynonyms)) {
1495-
return $onewaySynonyms;
1496-
}
1497-
return [];
1498-
}
1499-
1500-
/**
1501-
* @param $storeId
1502-
* @return string|null
1503-
* @throws Magento\Framework\Exception\FileSystemException
1504-
*/
1505-
public function getSynonymsFile($storeId = null)
1506-
{
1507-
$filename = $this->configInterface->getValue(self::SYNONYMS_FILE, ScopeInterface::SCOPE_STORE, $storeId);
1508-
if (!$filename) {
1509-
return null;
1510-
}
1511-
$baseDirectory = $this->directoryList->getPath(DirectoryList::MEDIA);
1512-
return $baseDirectory . '/algoliasearch_admin_config_uploads/' . $filename;
1513-
}
1514-
15151452
/**
15161453
* @param $storeId
15171454
* @return bool

Helper/Configuration/AssetHelper.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class AssetHelper extends \Magento\Framework\App\Helper\AbstractHelper
4040
'url' => 'https://www.youtube.com/watch?v=0V1BSKlCm10',
4141
'thumbnail' => 'https://img.youtube.com/vi/0V1BSKlCm10/mqdefault.jpg',
4242
],
43-
'algoliasearch_synonyms' => [
44-
'title' => 'Notable features',
45-
'url' => 'https://www.youtube.com/watch?v=45NKJbrs1Z4',
46-
'thumbnail' => 'https://img.youtube.com/vi/45NKJbrs1Z4/mqdefault.jpg',
47-
],
4843
'algoliasearch_cc_analytics' => [
4944
'title' => 'Notable features',
5045
'url' => 'https://www.youtube.com/watch?v=45NKJbrs1Z4',
@@ -143,13 +138,6 @@ class AssetHelper extends \Magento\Framework\App\Helper\AbstractHelper
143138
'icon' => 'iconDocs',
144139
],
145140
],
146-
'algoliasearch_synonyms' => [
147-
[
148-
'title' => 'Synonyms documentation',
149-
'url' => 'https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/?utm_source=magento&utm_medium=extension&utm_campaign=magento_2&utm_term=shop-owner&utm_content=doc-link',
150-
'icon' => 'iconDocs',
151-
],
152-
],
153141
'algoliasearch_cc_analytics' => [
154142
[
155143
'title' => 'Click & Conversion Analytics',

Helper/Entity/ProductHelper.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -500,46 +500,6 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
500500
// Commented out as it doesn't delete anything now because of merging replica indices earlier
501501
// $this->deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId);
502502

503-
if ($this->configHelper->isEnabledSynonyms($storeId) === true) {
504-
if ($synonymsFile = $this->configHelper->getSynonymsFile($storeId)) {
505-
$synonymsToSet = json_decode(file_get_contents($synonymsFile), true);
506-
} else {
507-
$synonymsToSet = [];
508-
509-
$synonyms = $this->configHelper->getSynonyms($storeId);
510-
foreach ($synonyms as $objectID => $synonym) {
511-
$synonymsToSet[] = [
512-
'objectID' => $objectID,
513-
'type' => 'synonym',
514-
'synonyms' => $this->explodeSynonyms($synonym['synonyms']),
515-
];
516-
}
517-
518-
$onewaySynonyms = $this->configHelper->getOnewaySynonyms($storeId);
519-
foreach ($onewaySynonyms as $objectID => $onewaySynonym) {
520-
$synonymsToSet[] = [
521-
'objectID' => $objectID,
522-
'type' => 'oneWaySynonym',
523-
'input' => $onewaySynonym['input'],
524-
'synonyms' => $this->explodeSynonyms($onewaySynonym['synonyms']),
525-
];
526-
}
527-
}
528-
529-
$this->algoliaHelper->setSynonyms($indexName, $synonymsToSet);
530-
$this->logger->log('Setting synonyms to "' . $indexName . '"');
531-
if ($saveToTmpIndicesToo === true) {
532-
$this->algoliaHelper->setSynonyms($indexNameTmp, $synonymsToSet);
533-
$this->logger->log('Setting synonyms to "' . $indexNameTmp . '"');
534-
}
535-
} elseif ($saveToTmpIndicesToo === true) {
536-
$this->algoliaHelper->copySynonyms($indexName, $indexNameTmp);
537-
$this->logger->log('
538-
Synonyms management disabled.
539-
Copying synonyms from production index to TMP one to not to erase them with the index move.
540-
');
541-
}
542-
543503
if ($saveToTmpIndicesToo === true) {
544504
try {
545505
$this->algoliaHelper->copyQueryRules($indexName, $indexNameTmp);
@@ -1344,15 +1304,6 @@ protected function clearFacetsQueryRules(SearchIndex $index)
13441304
}
13451305
}
13461306

1347-
/**
1348-
* @param $synonyms
1349-
* @return array
1350-
*/
1351-
protected function explodeSynonyms($synonyms)
1352-
{
1353-
return array_map('trim', explode(',', $synonyms));
1354-
}
1355-
13561307
/**
13571308
* Check if product can be index on Algolia
13581309
*

Model/Source/OnewaySynonyms.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

Model/Source/Synonyms.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

Model/Source/SynonymsFile.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

etc/adminhtml/system.xml

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -779,62 +779,10 @@
779779
<resource>Algolia_AlgoliaSearch::algolia_algoliasearch</resource>
780780
<group id="synonyms_group" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
781781
<label>Synonyms</label>
782-
<comment>
783-
<![CDATA[
784-
<div class="algolia-admin-content"></div>
785-
]]>
786-
</comment>
787-
<field id="enable_synonyms" translate="label comment" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
788-
<label>Enable Synonyms Management</label>
789-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
782+
<field id="notice" translate="label comment" type="label" sortOrder="10" showInDefault="1">
783+
<label>Notice:</label>
790784
<comment>
791-
<![CDATA[
792-
Do you want to manage <a target="_blank" href="https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/?utm_source=magento&utm_medium=extension&utm_campaign=magento_2&utm_term=shop-owner&utm_content=doc-link">synonyms</a> in Magento?
793-
If not, synonyms will be managed only in <a target="_blank" href="https://www.algolia.com/dashboard/">Algolia's dashboard</a> and won't be overridden by Magento.
794-
]]>
795-
</comment>
796-
</field>
797-
<field id="synonyms" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
798-
<label>Synonyms</label>
799-
<frontend_model>Algolia\AlgoliaSearch\Model\Source\Synonyms</frontend_model>
800-
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
801-
<comment>
802-
<![CDATA[
803-
<a href="https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/?utm_source=magento&utm_medium=extension&utm_campaign=magento_2&utm_term=shop-owner&utm_content=doc-link#regular-synonyms-default" target="_blank">Synonyms</a> can be defined by a comma-separated list of words that will be considered equivalent by the Algolia engine.<br>
804-
For instance: <code>tv, television, tv set</code><br>
805-
Using that set, if a record contains “television” and a user searches for “TV”, this record will be returned.
806-
]]>
807-
</comment>
808-
</field>
809-
<field id="oneway_synonyms" translate="label comment" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
810-
<label>One-way Synonyms</label>
811-
<frontend_model>Algolia\AlgoliaSearch\Model\Source\OnewaySynonyms</frontend_model>
812-
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
813-
<comment>
814-
<![CDATA[
815-
<a href="https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/?utm_source=magento&utm_medium=extension&utm_campaign=magento_2&utm_term=shop-owner&utm_content=doc-link#one-way-synonyms" target="_blank">One-way synonyms</a>
816-
allow you to define alternative words for a search term, which are not synonyms to each other.<br>
817-
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”.<br>
818-
To do this, you’d define a one-way synonym set between <code>tablet</code> (as input) and <code>ipad, galaxy note</code> (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”.
819-
<br>
820-
<br>
821-
Algolia offers more synonymys’ types - placeholders and alternative corrections. These types can be managed directly from your <a href="https://www.algolia.com/dashboard" target="_blank">Algolia’s dashboard</a>.
822-
Any changes you make to placeholders and alternative corrections in Algolia’s dashboard won’t be overridden.
823-
]]>
824-
</comment>
825-
</field>
826-
<field id="synonyms_file" translate="label comment" type="file" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
827-
<label>Synonyms File</label>
828-
<backend_model>Algolia\AlgoliaSearch\Model\Source\SynonymsFile</backend_model>
829-
<upload_dir config="system/filesystem/media" scope_info="1">algoliasearch_admin_config_uploads</upload_dir>
830-
<base_url type="media" scope_info="1">algoliasearch_admin_config_uploads</base_url>
831-
<comment>
832-
<![CDATA[
833-
If you have a large amount of synonyms (more than 1 hundred), you don't have to manually enter them in the inputs above.
834-
You can upload a <a href="https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/how-to/managing-synonyms-from-the-dashboard/?utm_source=magento&utm_medium=extension&utm_campaign=magento_2&utm_term=shop-owner&utm_content=doc-link&language=php#importing-synonyms-from-a-file" target="_blank">JSON file</a> with synonyms instead.
835-
<br><span class="algolia-config-warning">&#9888;</span>
836-
When you upload a JSON file, all the synonyms settings from above will be ignored and only synonyms from the JSON file will be pushed to Algolia.
837-
]]>
785+
<![CDATA[Configurations related to Synonyms have been deprecated from the Magento dashboard. We advise you to configure synonyms from the Algolia dashboard]]>
838786
</comment>
839787
</field>
840788
</group>

0 commit comments

Comments
 (0)