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.
Merge pull request Smile-SA#38 from Elastic-Suite/feat-ESP-90-Columns
[Campaign Optimizer] Add columns in optimizer grid #ESP-90
- Loading branch information
Showing
7 changed files
with
235 additions
and
0 deletions.
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
57 changes: 57 additions & 0 deletions
57
...module-elasticsuite-ab-campaign/Ui/DataProvider/Optimizer/AddCampaignDataToCollection.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,57 @@ | ||
<?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\ElasticsuiteAbCampaign | ||
* @author Pierre LE MAGUER <[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\ElasticsuiteAbCampaign\Ui\DataProvider\Optimizer; | ||
|
||
use Magento\Framework\Data\Collection; | ||
use Magento\Ui\DataProvider\AddFieldToCollectionInterface; | ||
use Smile\ElasticsuiteCatalogOptimizer\Model\ResourceModel\Optimizer\Collection as OptimizerCollection; | ||
use Smile\ElasticsuiteAbCampaign\Model\ResourceModel\Campaign\Optimizer as CampaignOptimizerResource; | ||
|
||
/** | ||
* Class AddCampaignDataToCollection | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteAbCampaign | ||
* @author Pierre Le Maguer <[email protected]> | ||
*/ | ||
class AddCampaignDataToCollection implements AddFieldToCollectionInterface | ||
{ | ||
/** | ||
* @var CampaignOptimizerResource | ||
*/ | ||
private $campaignOptimizerResource; | ||
|
||
/** | ||
* AddCampaignDataToCollection constructor | ||
* | ||
* @param CampaignOptimizerResource $campaignOptimizerResource Campaign optimizer resource | ||
*/ | ||
public function __construct(CampaignOptimizerResource $campaignOptimizerResource) | ||
{ | ||
$this->campaignOptimizerResource = $campaignOptimizerResource; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function addField(Collection $collection, $field, $condition = null) | ||
{ | ||
/** @var OptimizerCollection $collection */ | ||
$this->campaignOptimizerResource->addCampaignDataToOptimizerCollection($collection); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...dule-elasticsuite-ab-campaign/Ui/DataProvider/Optimizer/AddCampaignFilterToCollection.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,69 @@ | ||
<?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\ElasticsuiteAbCampaign | ||
* @author Pierre LE MAGUER <[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\ElasticsuiteAbCampaign\Ui\DataProvider\Optimizer; | ||
|
||
use Magento\Framework\Data\Collection; | ||
use Magento\Ui\DataProvider\AddFilterToCollectionInterface; | ||
use Smile\ElasticsuiteCatalogOptimizer\Model\ResourceModel\Optimizer\Collection as OptimizerCollection; | ||
use Smile\ElasticsuiteAbCampaign\Model\ResourceModel\Campaign\Optimizer as CampaignOptimizerResource; | ||
|
||
/** | ||
* Class AddCampaignFilterToCollection | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteAbCampaign | ||
* @author Pierre Le Maguer <[email protected]> | ||
*/ | ||
class AddCampaignFilterToCollection implements AddFilterToCollectionInterface | ||
{ | ||
/** | ||
* @var CampaignOptimizerResource | ||
*/ | ||
private $campaignOptimizerResource; | ||
|
||
/** | ||
* AddCampaignDataToCollection constructor | ||
* | ||
* @param CampaignOptimizerResource $campaignOptimizerResource Campaign optimizer resource | ||
*/ | ||
public function __construct(CampaignOptimizerResource $campaignOptimizerResource) | ||
{ | ||
$this->campaignOptimizerResource = $campaignOptimizerResource; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function addFilter(Collection $collection, $field, $condition = null) | ||
{ | ||
/** @var OptimizerCollection $collection */ | ||
$this->campaignOptimizerResource->addCampaignDataToOptimizerCollection($collection); | ||
switch ($field) { | ||
case 'campaign_name': | ||
if (isset($condition['like'])) { | ||
$collection->getSelect()->where('campaign.name like ?', $condition['like']); | ||
} | ||
break; | ||
case 'campaign_status': | ||
if (isset($condition['in'])) { | ||
$collection->getSelect()->where('campaign.status in (?)', $condition['in']); | ||
} | ||
break; | ||
} | ||
} | ||
} |
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
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
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
58 changes: 58 additions & 0 deletions
58
...-ab-campaign/view/adminhtml/ui_component/smile_elasticsuite_catalog_optimizer_listing.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,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* ElasticsuiteAbCampaign listing UI Component | ||
* | ||
* 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\ElasticsuiteAbCampaign | ||
* @author Pierre Le Maguer <[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. | ||
*/ | ||
--> | ||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> | ||
<columns name="smile_elasticsuite_catalog_optimizer_columns"> | ||
<column name="campaign_name"> | ||
<argument name="data" xsi:type="array"> | ||
<item name="config" xsi:type="array"> | ||
<item name="filter" xsi:type="string">text</item> | ||
<item name="add_field" xsi:type="boolean">true</item> | ||
<item name="label" xsi:type="string" translate="true">Campaign Name</item> | ||
<item name="sortOrder" xsi:type="number">55</item> | ||
</item> | ||
</argument> | ||
</column> | ||
<column name="campaign_status"> | ||
<argument name="data" xsi:type="array"> | ||
<item name="options" xsi:type="array"> | ||
<item name="draft" xsi:type="array"> | ||
<item name="value" xsi:type="string">draft</item> | ||
<item name="label" xsi:type="string" translate="true">Draft</item> | ||
</item> | ||
<item name="published" xsi:type="array"> | ||
<item name="value" xsi:type="string">published</item> | ||
<item name="label" xsi:type="string" translate="true">Published</item> | ||
</item> | ||
<item name="complete" xsi:type="array"> | ||
<item name="value" xsi:type="string">complete</item> | ||
<item name="label" xsi:type="string" translate="true">Complete</item> | ||
</item> | ||
</item> | ||
<item name="config" xsi:type="array"> | ||
<item name="filter" xsi:type="string">select</item> | ||
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> | ||
<item name="dataType" xsi:type="string">select</item> | ||
<item name="add_field" xsi:type="boolean">true</item> | ||
<item name="label" xsi:type="string" translate="true">Campaign Status</item> | ||
<item name="sortOrder" xsi:type="number">56</item> | ||
</item> | ||
</argument> | ||
</column> | ||
</columns> | ||
</listing> |