Skip to content

Changed Newsletter Enabled/Disable config settings by priority, store scope then default scope #31208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 24, 2021
3 changes: 2 additions & 1 deletion app/code/Magento/Customer/Block/Form/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontNewsletterSubscriptionDisabledForStoreViewAtRegistrationTest">
<annotations>
<features value="Newsletter"/>
<stories value="Disabled Newsletter Subscription for store View"/>
<title value="Disabled Newsletter Subscription for store View"/>
<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"/>
</before>
<after>
<magentoCLI command="config:set --scope=stores --scope-code=default newsletter/general/active 1" stepKey="enableSubscriptionForStore"/>
</after>
<actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<dontSeeElement selector="{{StorefrontCustomerCreateFormSection.signUpForNewsletter}}" stepKey="checkNoSubscriptionOption"/>
</test>
</tests>