3

When searching the products displayed page title is different in magento2. Before login display customer login title and after login shown correct title.Please help me any one.enter image description here

  • It's a custom template? – nuovecode Jul 31 '17 at 19:13
  • No, this is default magento search page – venkata prasad Aug 1 '17 at 4:51
  • have you got any solution? – Devidas Jun 29 '18 at 7:06
2

Solved it. The problem was when we use below block in any cms block or page or template file

Magento\Customer\Block\Form\Login

then above issue arise for that specific pages.

I saw that Magento\Customer\Block\Form\Login class was overriding _prepareLayout() function like this:

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

So I created a custom Block in app/code/MyVendor/MyModule/Block/Form/Login extending Magento\Customer\Block\Form\Login and overriding _prepareLayout() function like this:

<?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;
    }
}

And due to above code title of customer login page removed so, I have added title in app/design/frontend/Vendor/theme/Magento_Customer/layout/customer_account_login.xml before body :

<head>
        <title>Customer Login</title> 
 </head>

And the issue was solved!

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.