diff --git a/Block/Adminhtml/Marketing/CartRule.php b/Block/Adminhtml/Marketing/CartRule.php new file mode 100644 index 0000000..4a5c66b --- /dev/null +++ b/Block/Adminhtml/Marketing/CartRule.php @@ -0,0 +1,44 @@ +_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); + } +} diff --git a/Block/Adminhtml/Marketing/CatalogRule.php b/Block/Adminhtml/Marketing/CatalogRule.php new file mode 100644 index 0000000..f995c66 --- /dev/null +++ b/Block/Adminhtml/Marketing/CatalogRule.php @@ -0,0 +1,44 @@ +_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); + } +} diff --git a/Block/Adminhtml/Marketing/Giftcardaccount.php b/Block/Adminhtml/Marketing/Giftcardaccount.php new file mode 100644 index 0000000..821847c --- /dev/null +++ b/Block/Adminhtml/Marketing/Giftcardaccount.php @@ -0,0 +1,41 @@ +_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); + } +} diff --git a/Block/Adminhtml/Marketing/Targetrule.php b/Block/Adminhtml/Marketing/Targetrule.php new file mode 100644 index 0000000..618f31c --- /dev/null +++ b/Block/Adminhtml/Marketing/Targetrule.php @@ -0,0 +1,44 @@ +_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); + } +} diff --git a/Model/Config/Source/GiftCardAccountStatus.php b/Model/Config/Source/GiftCardAccountStatus.php new file mode 100644 index 0000000..8763dbe --- /dev/null +++ b/Model/Config/Source/GiftCardAccountStatus.php @@ -0,0 +1,35 @@ +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; + } +} diff --git a/Model/Config/Source/TargetRuleApplies.php b/Model/Config/Source/TargetRuleApplies.php new file mode 100644 index 0000000..91c4edf --- /dev/null +++ b/Model/Config/Source/TargetRuleApplies.php @@ -0,0 +1,34 @@ +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; + } +} diff --git a/Model/System/Configuration.php b/Model/System/Configuration.php index 16dc6ad..58ef959 100644 --- a/Model/System/Configuration.php +++ b/Model/System/Configuration.php @@ -18,6 +18,10 @@ class Configuration const XML_PATH_REPLACE_CUSTOMER_NOW_ONLINE_LISTING = "easy_admin_grids/customer/replace_now_online"; const XML_PATH_REPLACE_CUSTOMER_GROUP_LISTING = "easy_admin_grids/customer/replace_group"; const XML_PATH_REPLACE_CUSTOMER_SEGMENT_LISTING = "easy_admin_grids/customer/replace_segment"; + const XML_PATH_REPLACE_MARKETING_CATALOG_RULE_LISTING = "easy_admin_grids/marketing/replace_catalog_rule"; + const XML_PATH_REPLACE_MARKETING_RELATED_RULE_LISTING = "easy_admin_grids/marketing/replace_related_product_rule"; + const XML_PATH_REPLACE_MARKETING_CART_RULE_LISTING = "easy_admin_grids/marketing/replace_cart_rule"; + const XML_PATH_REPLACE_MARKETING_GIFT_ACC_RULE_LISTING = "easy_admin_grids/marketing/replace_giftacc_rule"; /**#@-*/ /** @@ -109,4 +113,48 @@ public function canReplaceCustomerSegmentListing() ScopeInterface::SCOPE_STORE ); } + + /** + * @return mixed + */ + public function canReplaceMarketingCatalogRuleListing() + { + return $this->scopeConfig->getValue( + self::XML_PATH_REPLACE_MARKETING_CATALOG_RULE_LISTING, + ScopeInterface::SCOPE_STORE + ); + } + + /** + * @return mixed + */ + public function canReplaceMarketingRelatedRuleListing() + { + return $this->scopeConfig->getValue( + self::XML_PATH_REPLACE_MARKETING_RELATED_RULE_LISTING, + ScopeInterface::SCOPE_STORE + ); + } + + /** + * @return mixed + */ + public function canReplaceMarketingCartRuleListing() + { + return $this->scopeConfig->getValue( + self::XML_PATH_REPLACE_MARKETING_CART_RULE_LISTING, + ScopeInterface::SCOPE_STORE + ); + } + + /** + * @return mixed + */ + public function canReplaceMarketingGiftAccountListing() + { + return $this->scopeConfig->getValue( + self::XML_PATH_REPLACE_MARKETING_GIFT_ACC_RULE_LISTING, + ScopeInterface::SCOPE_STORE + ); + } } diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index 8398bed..dda5d97 100644 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -5,5 +5,6 @@ Hyva_Admin::grid.phtml + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 6fc5df8..49f0b0b 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -52,6 +52,29 @@ Magento\Config\Model\Config\Source\Yesno + + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + diff --git a/view/adminhtml/hyva-grid/marketing-cart-rules-grid.xml b/view/adminhtml/hyva-grid/marketing-cart-rules-grid.xml new file mode 100644 index 0000000..c94ed4c --- /dev/null +++ b/view/adminhtml/hyva-grid/marketing-cart-rules-grid.xml @@ -0,0 +1,46 @@ + + + + \Magento\SalesRule\Api\RuleRepositoryInterface::getList + + + + + + + + + + + + + + + + + + + +