-
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 #3 from juashyam/marketing-grids-coverage
Marketing grids coverage
- Loading branch information
Showing
17 changed files
with
569 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Juashyam\EasyAdminGrids\Block\Adminhtml\Marketing; | ||
|
||
use Juashyam\EasyAdminGrids\Model\System\Configuration; | ||
use Magento\Backend\Block\Widget\Button; | ||
|
||
/** | ||
* Extend the grid container block of cart rules to display conditionally | ||
*/ | ||
class CartRule extends \Magento\SalesRule\Block\Adminhtml\Promo\Quote | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getGridHtml() | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_CART_RULE_LISTING) | ||
) { | ||
return ''; | ||
} | ||
|
||
return parent::getGridHtml(); | ||
} | ||
|
||
/** | ||
* Check whether button rendering is allowed in current context | ||
* | ||
* @param \Magento\Backend\Block\Widget\Button\Item $item | ||
* @return bool | ||
*/ | ||
public function canRender(Button\Item $item) | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_CART_RULE_LISTING) | ||
) { | ||
return false; | ||
} | ||
|
||
return parent::canRender($item); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Juashyam\EasyAdminGrids\Block\Adminhtml\Marketing; | ||
|
||
use Juashyam\EasyAdminGrids\Model\System\Configuration; | ||
use Magento\Backend\Block\Widget\Button; | ||
|
||
/** | ||
* Extend the grid container block of catalog rules to display conditionally | ||
*/ | ||
class CatalogRule extends \Magento\CatalogRule\Block\Adminhtml\Promo\Catalog | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getGridHtml() | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_CATALOG_RULE_LISTING) | ||
) { | ||
return ''; | ||
} | ||
|
||
return parent::getGridHtml(); | ||
} | ||
|
||
/** | ||
* Check whether button rendering is allowed in current context | ||
* | ||
* @param \Magento\Backend\Block\Widget\Button\Item $item | ||
* @return bool | ||
*/ | ||
public function canRender(Button\Item $item) | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_CATALOG_RULE_LISTING) | ||
) { | ||
return false; | ||
} | ||
|
||
return parent::canRender($item); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Juashyam\EasyAdminGrids\Block\Adminhtml\Marketing; | ||
|
||
use Juashyam\EasyAdminGrids\Model\System\Configuration; | ||
use Magento\Backend\Block\Widget\Button; | ||
|
||
class Giftcardaccount extends \Magento\GiftCardAccount\Block\Adminhtml\Giftcardaccount | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getGridHtml() | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_GIFT_ACC_RULE_LISTING) | ||
) { | ||
return ''; | ||
} | ||
|
||
return parent::getGridHtml(); | ||
} | ||
|
||
/** | ||
* Check whether button rendering is allowed in current context | ||
* | ||
* @param \Magento\Backend\Block\Widget\Button\Item $item | ||
* @return bool | ||
*/ | ||
public function canRender(Button\Item $item) | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_GIFT_ACC_RULE_LISTING) | ||
) { | ||
return false; | ||
} | ||
|
||
return parent::canRender($item); | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Juashyam\EasyAdminGrids\Block\Adminhtml\Marketing; | ||
|
||
use Juashyam\EasyAdminGrids\Model\System\Configuration; | ||
use Magento\Backend\Block\Widget\Button; | ||
|
||
/** | ||
* Extend the grid container block of related product rules to display conditionally | ||
*/ | ||
class Targetrule extends \Magento\TargetRule\Block\Adminhtml\Targetrule | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getGridHtml() | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_RELATED_RULE_LISTING) | ||
) { | ||
return ''; | ||
} | ||
|
||
return parent::getGridHtml(); | ||
} | ||
|
||
/** | ||
* Check whether button rendering is allowed in current context | ||
* | ||
* @param \Magento\Backend\Block\Widget\Button\Item $item | ||
* @return bool | ||
*/ | ||
public function canRender(Button\Item $item) | ||
{ | ||
if ($this->_scopeConfig->isSetFlag(Configuration::XML_PATH_IS_ENABLED) | ||
&& $this->_scopeConfig->isSetFlag(Configuration::XML_PATH_REPLACE_MARKETING_RELATED_RULE_LISTING) | ||
) { | ||
return false; | ||
} | ||
|
||
return parent::canRender($item); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Juashyam\EasyAdminGrids\Model\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Magento\GiftCardAccount\Model\Giftcardaccount; | ||
|
||
/** | ||
* Gift Card Account Status options | ||
*/ | ||
class GiftCardAccountStatus implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $options; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
if (!$this->options) { | ||
$this->options = [ | ||
['value' => Giftcardaccount::STATE_AVAILABLE, 'label' => __('Available')], | ||
['value' => Giftcardaccount::STATE_USED, 'label' => __('Used')], | ||
['value' => Giftcardaccount::STATE_REDEEMED, 'label' => __('Redeemed')], | ||
['value' => Giftcardaccount::STATE_EXPIRED, 'label' => __('Expired')] | ||
]; | ||
} | ||
|
||
return $this->options; | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Juashyam\EasyAdminGrids\Model\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Magento\TargetRule\Model\Rule; | ||
|
||
/** | ||
* Target Rule applies to options | ||
*/ | ||
class TargetRuleApplies implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $options; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
if (!$this->options) { | ||
$this->options = [ | ||
['value' => Rule::RELATED_PRODUCTS, 'label' => __('Related Products')], | ||
['value' => Rule::UP_SELLS, 'label' => __('Up-sells')], | ||
['value' => Rule::CROSS_SELLS, 'label' => __('Cross-sells')] | ||
]; | ||
} | ||
|
||
return $this->options; | ||
} | ||
} |
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
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,46 @@ | ||
<?xml version="1.0"?> | ||
<grid xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Hyva_Admin:etc/hyva-grid.xsd"> | ||
<source> | ||
<repositoryListMethod>\Magento\SalesRule\Api\RuleRepositoryInterface::getList</repositoryListMethod> | ||
</source> | ||
<columns> | ||
<include> | ||
<column name="rule_id" label="ID"/> | ||
<column name="name" label="Rule"/> | ||
<column name="sort_order" label="Priority"/> | ||
<column name="is_active" label="Status"> | ||
<option value="1" label="Active"/> | ||
<option value="0" label="Inactive"/> | ||
</column> | ||
<column name="website_ids" label="Web Site" type="website_id" source="\Magento\Store\Model\ResourceModel\Website\Collection"/> | ||
</include> | ||
</columns> | ||
<actions idColumn="rule_id"> | ||
<action id="edit" label="Edit" url="sales_rule/promo_quote/edit/" idParam="id"/> | ||
</actions> | ||
<entityConfig> | ||
<label> | ||
<singular>Cart Price Rule</singular> | ||
<plural>Cart Price Rules</plural> | ||
</label> | ||
</entityConfig> | ||
<navigation> | ||
<buttons> | ||
<button id="new" label="Add New Rule" url="sales_rule/promo_quote/new/"/> | ||
</buttons> | ||
<pager> | ||
<defaultPageSize>20</defaultPageSize> | ||
<pageSizes>20,30,50,100,200</pageSizes> | ||
</pager> | ||
<sorting> | ||
<defaultSortByColumn>sort_order</defaultSortByColumn> | ||
<defaultSortDirection>asc</defaultSortDirection> | ||
</sorting> | ||
<filters> | ||
<filter column="rule_id"/> | ||
<filter column="name"/> | ||
<filter column="sort_order"/> | ||
<filter column="is_active"/> | ||
</filters> | ||
</navigation> | ||
</grid> |
Oops, something went wrong.