From 170e227215345d40123196110c9521363287f293 Mon Sep 17 00:00:00 2001 From: juashyam Date: Sun, 27 Jun 2021 11:41:54 +0530 Subject: [PATCH 1/2] Replace marketing grids (Catalog Price, Related Products and Gift Card Accounts) --- Block/Adminhtml/Marketing/CatalogRule.php | 44 +++++++++++++ Block/Adminhtml/Marketing/Giftcardaccount.php | 41 ++++++++++++ Block/Adminhtml/Marketing/Targetrule.php | 44 +++++++++++++ Model/Config/Source/GiftCardAccountStatus.php | 35 ++++++++++ Model/Config/Source/TargetRuleApplies.php | 34 ++++++++++ Model/System/Configuration.php | 48 ++++++++++++++ etc/adminhtml/system.xml | 23 +++++++ .../hyva-grid/marketing-cart-rules-grid.xml | 48 ++++++++++++++ .../marketing-catalog-rules-grid.xml | 41 ++++++++++++ .../hyva-grid/marketing-gift-account-grid.xml | 49 ++++++++++++++ .../marketing-related-rules-grid.xml | 64 +++++++++++++++++++ .../adminhtml_giftcardaccount_index.xml | 14 ++++ .../layout/adminhtml_targetrule_index.xml | 14 ++++ .../catalog_rule_promo_catalog_index.xml | 14 ++++ 14 files changed, 513 insertions(+) create mode 100644 Block/Adminhtml/Marketing/CatalogRule.php create mode 100644 Block/Adminhtml/Marketing/Giftcardaccount.php create mode 100644 Block/Adminhtml/Marketing/Targetrule.php create mode 100644 Model/Config/Source/GiftCardAccountStatus.php create mode 100644 Model/Config/Source/TargetRuleApplies.php create mode 100644 view/adminhtml/hyva-grid/marketing-cart-rules-grid.xml create mode 100644 view/adminhtml/hyva-grid/marketing-catalog-rules-grid.xml create mode 100644 view/adminhtml/hyva-grid/marketing-gift-account-grid.xml create mode 100644 view/adminhtml/hyva-grid/marketing-related-rules-grid.xml create mode 100644 view/adminhtml/layout/adminhtml_giftcardaccount_index.xml create mode 100644 view/adminhtml/layout/adminhtml_targetrule_index.xml create mode 100644 view/adminhtml/layout/catalog_rule_promo_catalog_index.xml 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/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..2150ba7 --- /dev/null +++ b/view/adminhtml/hyva-grid/marketing-cart-rules-grid.xml @@ -0,0 +1,48 @@ + + + + \Magento\SalesRule\Model\ResourceModel\Rule\Quote\Collection + + + + + + + + + + + + + + + + + + + + +