forked from Smile-SA/elasticsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESP-315 [Behavioral Optimizers] ln1p deprecation
- Loading branch information
Showing
3 changed files
with
138 additions
and
18 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...-elasticsuite-behavioral-optimizer/Ui/Component/Optimizer/Form/Modifier/ScaleFunction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteBehavioralOptimizer | ||
* @author Richard Bayet <[email protected]> | ||
* @copyright 2021 Smile | ||
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided. | ||
* Unauthorized copying of this file, via any medium, is strictly prohibited. | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteBehavioralOptimizer\Ui\Component\Optimizer\Form\Modifier; | ||
|
||
use Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Locator\LocatorInterface as OptimizerLocatorInterface; | ||
|
||
/** | ||
* Optimizer create/edit form UI component scale function modifier. | ||
* Allows the choice of 'ln1p' as a scale function if in edit mode and the optimizer already uses it. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteBehavioralOptimizer | ||
* @author Richard Bayet <[email protected]> | ||
*/ | ||
class ScaleFunction implements \Magento\Ui\DataProvider\Modifier\ModifierInterface | ||
{ | ||
/** | ||
* @var OptimizerLocatorInterface | ||
*/ | ||
private $locator; | ||
|
||
/** | ||
* Search Terms constructor. | ||
* | ||
* @param OptimizerLocatorInterface $locator Optimizer Locator | ||
*/ | ||
public function __construct(OptimizerLocatorInterface $locator) | ||
{ | ||
$this->locator = $locator; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function modifyData(array $data) | ||
{ | ||
return $data; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function modifyMeta(array $meta) | ||
{ | ||
$optimizer = $this->locator->getOptimizer(); | ||
|
||
$scaleFunctionsOptions = [ | ||
['value' => 'log1p', 'label' => __('Low')], | ||
['value' => 'sqrt', 'label' => __('Medium')], | ||
['value' => 'none', 'label' => __('High')], | ||
]; | ||
$optionsTooltips = [ | ||
'log1p' => __('behavioral log1p desc'), | ||
'sqrt' => __('behavioral sqrt desc'), | ||
'none' => __('behavioral none desc'), | ||
]; | ||
$scaleFunctionChartFunctions = [ | ||
'log1p' => 'log1p', | ||
'sqrt' => 'sqrt', | ||
'none' => 'none', | ||
]; | ||
|
||
if ($optimizer && $optimizer->getId()) { | ||
$scaleFunction = $optimizer->getConfig('scale_function'); | ||
if ($scaleFunction === 'ln1p') { | ||
$scaleFunctionsOptions = array_merge( | ||
[['value' => 'ln1p', 'label' => __('Low (deprecated)')]], | ||
$scaleFunctionsOptions | ||
); | ||
$optionsTooltips = array_merge( | ||
['ln1p' => __('behavioral ln1p desc')], | ||
$optionsTooltips | ||
); | ||
$scaleFunctionChartFunctions = array_merge( | ||
['ln1p' => 'ln1p'], | ||
$scaleFunctionChartFunctions | ||
); | ||
} | ||
} | ||
|
||
$meta['behavioral']['children']['scale_function']['arguments']['data']['config']['options'] = $scaleFunctionsOptions; | ||
$meta['behavioral']['children']['scale_function']['arguments']['data']['config']['optionsTooltips'] = $optionsTooltips; | ||
$meta['behavioral']['children']['scale_function_chart']['arguments']['data']['config']['functions'] = $scaleFunctionChartFunctions; | ||
|
||
return $meta; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/module-elasticsuite-behavioral-optimizer/etc/adminhtml/di.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Smile\ElasticsuiteBehavioralOptimizer adminhtml dependency injection configuration. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteBehavioralOptimizer | ||
* @author Richard Bayet <[email protected]> | ||
* @copyright 2021 Smile | ||
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided. | ||
* Unauthorized copying of this file, via any medium, is strictly prohibited. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
|
||
<virtualType name="Smile\ElasticsuiteCatalogOptimizer\Ui\Component\Optimizer\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool"> | ||
<arguments> | ||
<argument name="modifiers" xsi:type="array"> | ||
<item name="behavioral_scale_function" xsi:type="array"> | ||
<item name="class" xsi:type="string">Smile\ElasticsuiteBehavioralOptimizer\Ui\Component\Optimizer\Form\Modifier\ScaleFunction</item> | ||
<item name="sortOrder" xsi:type="number">50</item> | ||
</item> | ||
</argument> | ||
</arguments> | ||
</virtualType> | ||
|
||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters