Question

I am trying to change the title of the /newsletter/manage/ page. Can anyone guide me?

Was it helpful?

Solution

You can do that by overriding the \Magento\Newsletter\Controller\Manage\Index controller.

di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Newsletter\Controller\Manage\Index" type="Myvendor\Mymodule\Controller\Override\Manage\Index" />
</config>

\Myvendor\Mymodule\Controller\Override\Manage\Index class:

<?php
namespace Myvendor\Mymodule\Controller\Override\Manage;

class Index extends \Magento\Newsletter\Controller\Manage\Index
{
    public function execute()
    {
        $this->_view->loadLayout();

        if ($block = $this->_view->getLayout()->getBlock('customer_newsletter')) {
            $block->setRefererUrl($this->_redirect->getRefererUrl());
        }
        $this->_view->getPage()->getConfig()->getTitle()->set(__('[[My custom title]]'));
        $this->_view->renderLayout();
    }
}

Replacing the [[My custom title]] with your title

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top