Here is the Page Title solution for M2 while you are using ‘Magento\Customer\Block\Form\Register’ or ‘Magento\Customer\Block\Form\Login’ class to extend in your custom block.
I have found that when we are using this to extend our custom block they make changes in page titles in some of the pages like order success page.
After struggeling for sometime I have found a patch we can use. Hopefully useful for someone
/**
* @return $this
* @author Karan Popat <krn.ppt@gmail.com>
*/
protected function _prepareLayout()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$request = $objectManager->get('\Magento\Framework\App\Request\Http');
if($request->getFullActionName() == 'customer_account_create') {
$this->pageConfig->getTitle()->set(__('Create New Customer Account'));
}
}
Here you can replace ‘customer_account_create’ with relevant action name for the block you have extended and set title accordingly. i.e.
Magento\Customer\Block\Form\Register => customer_account_create
Magento\Customer\Block\Form\Login => customer_account_login
Hi thanks for this post. Can you write entire code for modifying Customer Registration page title ?
LikeLike
I am stuck from a long time.
LikeLike