From 1de30e394110c0fb284994c4da73390530462723 Mon Sep 17 00:00:00 2001 From: saphaljha Date: Tue, 8 Dec 2020 19:10:15 +0530 Subject: [PATCH 1/4] Changed config to store before default --- app/code/Magento/Newsletter/Model/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Newsletter/Model/Config.php b/app/code/Magento/Newsletter/Model/Config.php index c469d35e74f72..eba0980e993b2 100644 --- a/app/code/Magento/Newsletter/Model/Config.php +++ b/app/code/Magento/Newsletter/Model/Config.php @@ -41,7 +41,7 @@ public function __construct( * @param string $scopeType * @return bool */ - public function isActive(string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT): bool + public function isActive(string $scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_STORE): bool { return $this->scopeConfig->isSetFlag(self::XML_PATH_NEWSLETTER_ACTIVE, $scopeType); } From 7889a6ffe566b7e13fa74877b0a7c3cf82cb9e45 Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Wed, 23 Dec 2020 17:56:20 +0200 Subject: [PATCH 2/4] Fix has been updated --- app/code/Magento/Customer/Block/Form/Register.php | 3 ++- app/code/Magento/Newsletter/Model/Config.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Block/Form/Register.php b/app/code/Magento/Customer/Block/Form/Register.php index d6d0d9c494c11..006deed601274 100644 --- a/app/code/Magento/Customer/Block/Form/Register.php +++ b/app/code/Magento/Customer/Block/Form/Register.php @@ -9,6 +9,7 @@ use Magento\Customer\Model\AccountManagement; use Magento\Framework\App\ObjectManager; use Magento\Newsletter\Model\Config; +use Magento\Store\Model\ScopeInterface; /** * Customer register form block @@ -184,7 +185,7 @@ public function getRegion() public function isNewsletterEnabled() { return $this->_moduleManager->isOutputEnabled('Magento_Newsletter') - && $this->newsLetterConfig->isActive(); + && $this->newsLetterConfig->isActive(ScopeInterface::SCOPE_STORE); } /** diff --git a/app/code/Magento/Newsletter/Model/Config.php b/app/code/Magento/Newsletter/Model/Config.php index eba0980e993b2..c469d35e74f72 100644 --- a/app/code/Magento/Newsletter/Model/Config.php +++ b/app/code/Magento/Newsletter/Model/Config.php @@ -41,7 +41,7 @@ public function __construct( * @param string $scopeType * @return bool */ - public function isActive(string $scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_STORE): bool + public function isActive(string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT): bool { return $this->scopeConfig->isSetFlag(self::XML_PATH_NEWSLETTER_ACTIVE, $scopeType); } From 21c0bff1cf8e5ffcd73145574d9595d8625f53f3 Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Wed, 23 Dec 2020 19:11:33 +0200 Subject: [PATCH 3/4] Test has been added --- ...DisabledForStoreViewAtRegistrationTest.xml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml new file mode 100644 index 0000000000000..e49948e9d2aa8 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + <description value="Option to subscribe should not be displayed at registration form if it is switched off for current store"/> + <severity value="AVERAGE"/> + <group value="newsletter"/> + <group value="configuration"/> + <testCaseId value="MC-*"/> + </annotations> + <before> + <magentoCLI command="config:set --scope=stores --scope-code=default newsletter/general/active 0" stepKey="disableSubscriptionForStore"/> + <magentoCLI command="cache:clean config" stepKey="cleanCache"/> + </before> + <after> + <magentoCLI command="config:set --scope=stores --scope-code=default newsletter/general/active 1" stepKey="enableSubscriptionForStore"/> + <magentoCLI command="cache:clean config" stepKey="cleanCacheAgain"/> + </after> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <dontSeeElement selector="{{StorefrontCustomerCreateFormSection.signUpForNewsletter}}" stepKey="checkNoSubscriptionOption"/> + </test> +</tests> From d099df94da8f8fb3626151b71b94aed26df1987d Mon Sep 17 00:00:00 2001 From: "taras.gamanov" <engcom-vendorworker-hotel@adobe.com> Date: Tue, 12 Jan 2021 10:47:19 +0200 Subject: [PATCH 4/4] 30667 - in progress --- ...letterSubscriptionDisabledForStoreViewAtRegistrationTest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml index e49948e9d2aa8..bc273d84aaf34 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest.xml @@ -21,11 +21,9 @@ </annotations> <before> <magentoCLI command="config:set --scope=stores --scope-code=default newsletter/general/active 0" stepKey="disableSubscriptionForStore"/> - <magentoCLI command="cache:clean config" stepKey="cleanCache"/> </before> <after> <magentoCLI command="config:set --scope=stores --scope-code=default newsletter/general/active 1" stepKey="enableSubscriptionForStore"/> - <magentoCLI command="cache:clean config" stepKey="cleanCacheAgain"/> </after> <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> <waitForPageLoad stepKey="waitForPageLoad"/>