To disable the Newsletter popup extension in your Magento 2 manually, you need to add this code to the XML layout:
<referenceBlock name="newsletter.popup">
<action method="disable" />
</referenceBlock>
Code Example
<body>
<referenceContainer name="root">
<referenceBlock name="newsletter.popup">
<action method="disable" />
</referenceBlock>
....
</referenceContainer>
</body>
In order to disable Newsletter Popup Extension using controller class, please use the following code:
$newsletterBlock = $this->_view->loadLayout()->getLayout()->getBlock('newsletter.popup');
if ($newsletterBlock) {
$newsletterBlock->disable();
}
Code Example
namespace MagentoContactControllerIndex;
class Index extends MagentoContactControllerIndex
{
public function execute()
{
$this->_view->loadLayout();
$newsletterBlock = $this->_view->loadLayout()->getLayout()
->getBlock('newsletter.popup');
if ($newsletterBlock) {
$newsletterBlock->disable();
}
$this->_view->renderLayout();
}
}
Was this article helpful?