1

My Contact Us page, Password Reset, Forgotten password and possibly a few other pages are having their page title overriten to say "Customer Login". I have a feeling that the culprit is located here,...

vendor\magento\module-customer\Block\Form\Login.php

    protected function _prepareLayout()
    {
        $this->pageConfig->getTitle()->set(__('Customer Login'));
        return parent::_prepareLayout();
    }

My layout files seem to be ignored and the title does not actually change. For example,

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Forgot Your Password</title>
    </head>
    <body>
        <referenceBlock name="root">
            <action method="setHeaderTitle">
                <argument translate="true" name="title" xsi:type="string">Password forgotten</argument>
            </action>
        </referenceBlock>
        <referenceContainer name="content">
            <block class="Magento\Customer\Block\Account\Forgotpassword" name="forgotPassword" template="Magento_Customer::form/forgotpassword.phtml">
                <container name="form.additional.info" as="form_additional_info"/>
            </block>
        </referenceContainer>
    </body>
</page>

does not actually do anything

I was able to find some hints on this stack post but it did not seem to do the trick.

0

I was able to find my answer by looking at a couple different posts. I went ahead and followed This Post and created my class and saving it in MyVendor\MyModule\Block\Form as Login.php

<?php

namespace MyVendor\MyModule\Block\Form;

use Magento\Customer\Block\Form\Login as BaseLogin;

class Login extends BaseLogin
{
    /**
     * @return $this
     */
    protected function _prepareLayout()
    {
        return $this;
    }
}

then edited my di.xml in MyVendor\MyModule\etc to include

<preference for="Magento\Customer\Block\Form\Login" type="MyVendor\MyModule\Block\Form\Login" />

More information on the cause of the issue can be found on this stack post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.