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.
Fix Smile-SA#1846 optimizer preview with search context
- Loading branch information
1 parent
207c5d9
commit ce45618
Showing
3 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
src/module-elasticsuite-catalog-optimizer/Plugin/Adminhtml/OptimizerFilter.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,66 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade Smile Elastic Suite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalogOptimizer | ||
* @author Romain Ruaud <[email protected]> | ||
* @copyright 2020 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCatalogOptimizer\Plugin\Adminhtml; | ||
|
||
use Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\OptimizerFilterInterface; | ||
|
||
/** | ||
* Adminhtml only plugin, used to append the currently previewed optimizers (if any) to the list of allowed ones. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalogOptimizer | ||
* @author Romain Ruaud <[email protected]> | ||
*/ | ||
class OptimizerFilter | ||
{ | ||
/** | ||
* @var \Magento\Framework\App\RequestInterface | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* OptimizerFilter constructor. | ||
* | ||
* @param \Magento\Framework\App\RequestInterface $request The request | ||
*/ | ||
public function __construct(\Magento\Framework\App\RequestInterface $request) | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* Append currently edited optimizer into available list. | ||
* | ||
* @param \Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\OptimizerFilterInterface $subject Optimizer Filter | ||
* @param $result Available Optimizers | ||
* | ||
* @return mixed | ||
*/ | ||
public function afterGetOptimizerIds(OptimizerFilterInterface $subject, $result) | ||
{ | ||
$result[] = $this->getCurrentOptimizerId(); | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Get current optimizer id | ||
* | ||
* @return string | ||
*/ | ||
private function getCurrentOptimizerId() | ||
{ | ||
return $this->request->getPostValue('optimizer_id') ?? ''; | ||
} | ||
} |
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