Zend certified PHP/Magento developer

Overriding /public_html/vendor/magento/module-customer/view/adminhtml/templates/tab/view/personal_info.phtml

I’m with a need to override admin area template /public_html/vendor/magento/module-customer/view/adminhtml/templates/tab/view/personal_info.phtml

I tried doing that with following.Just for testing whether overriding works, I am trying to change the font color of address section in personal info tab. The attempted overriding does not work and I do appreciate if someone guide me to the correct approach of overriding this tempalte.

Vendor/Module/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Customer" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Customer"/>
        </sequence>
    </module>
</config>

Block Vendor/Module/Block/Edit/Tab/ViewPersonalInfo.php

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorModuleBlockAdminhtmlEditTabView;
use MagentoCustomerApiAccountManagementInterface;
use MagentoCustomerControllerRegistryConstants;
use MagentoCustomerModelAddressMapper;
use MagentoFrameworkExceptionNoSuchEntityException;
use MagentoCustomerModelCustomer;
/**
* Adminhtml customer view personal information sales block.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class PersonalInfo extends MagentoBackendBlockTemplate
{
/**
* Interval in minutes that shows how long customer will be marked 'Online'
* since his last activity. Used only if it's impossible to get such setting
* from configuration.
*/
const DEFAULT_ONLINE_MINUTES_INTERVAL = 15;
/**
* Customer
*
* @var MagentoCustomerApiDataCustomerInterface
*/
protected $customer;
/**
* Customer log
*
* @var MagentoCustomerModelLog
*/
protected $customerLog;
/**
* Customer logger
*
* @var MagentoCustomerModelLogger
*/
protected $customerLogger;
/**
* Customer registry
*
* @var MagentoCustomerModelCustomerRegistry
*/
protected $customerRegistry;
/**
* Account management
*
* @var AccountManagementInterface
*/
protected $accountManagement;
/**
* Customer group repository
*
* @var MagentoCustomerApiGroupRepositoryInterface
*/
protected $groupRepository;
/**
* Customer data factory
*
* @var MagentoCustomerApiDataCustomerInterfaceFactory
*/
protected $customerDataFactory;
/**
* Address helper
*
* @var MagentoCustomerHelperAddress
*/
protected $addressHelper;
/**
* Date time
*
* @var MagentoFrameworkStdlibDateTime
*/
protected $dateTime;
/**
* Core registry
*
* @var MagentoFrameworkRegistry
*/
protected $coreRegistry;
/**
* Address mapper
*
* @var Mapper
*/
protected $addressMapper;
/**
* Data object helper
*
* @var MagentoFrameworkApiDataObjectHelper
*/
protected $dataObjectHelper;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param AccountManagementInterface $accountManagement
* @param MagentoCustomerApiGroupRepositoryInterface $groupRepository
* @param MagentoCustomerApiDataCustomerInterfaceFactory $customerDataFactory
* @param MagentoCustomerHelperAddress $addressHelper
* @param MagentoFrameworkStdlibDateTime $dateTime
* @param MagentoFrameworkRegistry $registry
* @param Mapper $addressMapper
* @param MagentoFrameworkApiDataObjectHelper $dataObjectHelper
* @param MagentoCustomerModelLogger $customerLogger
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
AccountManagementInterface $accountManagement,
MagentoCustomerApiGroupRepositoryInterface $groupRepository,
MagentoCustomerApiDataCustomerInterfaceFactory $customerDataFactory,
MagentoCustomerHelperAddress $addressHelper,
MagentoFrameworkStdlibDateTime $dateTime,
MagentoFrameworkRegistry $registry,
Mapper $addressMapper,
MagentoFrameworkApiDataObjectHelper $dataObjectHelper,
MagentoCustomerModelLogger $customerLogger,
array $data = []
) {
$this->coreRegistry = $registry;
$this->accountManagement = $accountManagement;
$this->groupRepository = $groupRepository;
$this->customerDataFactory = $customerDataFactory;
$this->addressHelper = $addressHelper;
$this->dateTime = $dateTime;
$this->addressMapper = $addressMapper;
$this->dataObjectHelper = $dataObjectHelper;
$this->customerLogger = $customerLogger;
parent::__construct($context, $data);
}
/**
* Set customer registry
*
* @param MagentoFrameworkRegistry $customerRegistry
* @return void
* @deprecated 100.1.0
*/
public function setCustomerRegistry(MagentoCustomerModelCustomerRegistry $customerRegistry)
{
$this->customerRegistry = $customerRegistry;
}
/**
* Get customer registry
*
* @return MagentoCustomerModelCustomerRegistry
* @deprecated 100.1.0
*/
public function getCustomerRegistry()
{
if (!($this->customerRegistry instanceof MagentoCustomerModelCustomerRegistry)) {
return MagentoFrameworkAppObjectManager::getInstance()->get(
MagentoCustomerModelCustomerRegistry::class
);
} else {
return $this->customerRegistry;
}
}
/**
* Retrieve customer object
*
* @return MagentoCustomerApiDataCustomerInterface
*/
public function getCustomer()
{
if (!$this->customer) {
$this->customer = $this->customerDataFactory->create();
$data = $this->_backendSession->getCustomerData();
$this->dataObjectHelper->populateWithArray(
$this->customer,
$data['account'],
MagentoCustomerApiDataCustomerInterface::class
);
}
return $this->customer;
}
/**
* Retrieve customer id
*
* @return string|null
*/
public function getCustomerId()
{
return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
}
/**
* Retrieves customer log model
*
* @return MagentoCustomerModelLog
*/
protected function getCustomerLog()
{
if (!$this->customerLog) {
$this->customerLog = $this->customerLogger->get(
$this->getCustomer()->getId()
);
}
return $this->customerLog;
}
/**
* Returns customer's created date in the assigned store
*
* @return string
*/
public function getStoreCreateDate()
{
$createdAt = $this->getCustomer()->getCreatedAt();
try {
return $this->formatDate(
$createdAt,
IntlDateFormatter::MEDIUM,
true,
$this->getStoreCreateDateTimezone()
);
} catch (Exception $e) {
$this->_logger->critical($e);
return '';
}
}
/**
* Retrieve store default timezone from configuration
*
* @return string
*/
public function getStoreCreateDateTimezone()
{
return $this->_scopeConfig->getValue(
$this->_localeDate->getDefaultTimezonePath(),
MagentoStoreModelScopeInterface::SCOPE_STORE,
$this->getCustomer()->getStoreId()
);
}
/**
* Get customer creation date
*
* @return string
*/
public function getCreateDate()
{
return $this->formatDate(
$this->getCustomer()->getCreatedAt(),
IntlDateFormatter::MEDIUM,
true
);
}
/**
* Check if account is confirmed
*
* @return MagentoFrameworkPhrase
*/
public function getIsConfirmedStatus()
{
$id = $this->getCustomerId();
switch ($this->accountManagement->getConfirmationStatus($id)) {
case AccountManagementInterface::ACCOUNT_CONFIRMED:
return __('Confirmed');
case AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED:
return __('Confirmation Required');
case AccountManagementInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED:
return __('Confirmation Not Required');
}
return __('Indeterminate');
}
/**
* Retrieve store
*
* @return null|string
*/
public function getCreatedInStore()
{
return $this->_storeManager->getStore(
$this->getCustomer()->getStoreId()
)->getName();
}
/**
* Retrieve billing address html
*
* @return MagentoFrameworkPhrase|string
*/
public function getBillingAddressHtml()
{
try {
$address = $this->accountManagement->getDefaultBillingAddress($this->getCustomer()->getId());
} catch (NoSuchEntityException $e) {
return $this->escapeHtml(__('The customer does not have default billing address.'));
}
if ($address === null) {
return $this->escapeHtml(__('The customer does not have default billing address.'));
}
return $this->addressHelper->getFormatTypeRenderer(
'html'
)->renderArray(
$this->addressMapper->toFlatArray($address)
);
}
/**
* Retrieve group name
*
* @return string|null
*/
public function getGroupName()
{
$customer = $this->getCustomer();
if ($groupId = $customer->getId() ? $customer->getGroupId() : null) {
if ($group = $this->getGroup($groupId)) {
return $group->getCode();
}
}
return null;
}
/**
* Retrieve customer group by id
*
* @param int $groupId
* @return MagentoCustomerApiDataGroupInterface|null
*/
private function getGroup($groupId)
{
try {
$group = $this->groupRepository->getById($groupId);
} catch (NoSuchEntityException $e) {
$group = null;
}
return $group;
}
/**
* Returns timezone of the store to which customer assigned.
*
* @return string
*/
public function getStoreLastLoginDateTimezone()
{
return $this->_scopeConfig->getValue(
$this->_localeDate->getDefaultTimezonePath(),
MagentoStoreModelScopeInterface::SCOPE_STORE,
$this->getCustomer()->getStoreId()
);
}
/**
* Get customer's current status.
*
* Customer considered 'Offline' in the next cases:
*
* - customer has never been logged in;
* - customer clicked 'Log Out' linkbutton;
* - predefined interval has passed since customer's last activity.
*
* In all other cases customer considered 'Online'.
*
* @return MagentoFrameworkPhrase
*/
public function getCurrentStatus()
{
$lastLoginTime = $this->getCustomerLog()->getLastLoginAt();
// Customer has never been logged in.
if (!$lastLoginTime) {
return __('Offline');
}
$lastLogoutTime = $this->getCustomerLog()->getLastLogoutAt();
// Customer clicked 'Log Out' linkbutton.
if ($lastLogoutTime && strtotime($lastLogoutTime) > strtotime($lastLoginTime)) {
return __('Offline');
}
// Predefined interval has passed since customer's last activity.
$interval = $this->getOnlineMinutesInterval();
$currentTimestamp = (new DateTime())->getTimestamp();
$lastVisitTime = $this->getCustomerLog()->getLastVisitAt();
if ($lastVisitTime && $currentTimestamp - strtotime($lastVisitTime) > $interval * 60) {
return __('Offline');
}
return __('Online');
}
/**
* Get customer last login date.
*
* @return MagentoFrameworkPhrase|string
*/
public function getLastLoginDate()
{
$date = $this->getCustomerLog()->getLastLoginAt();
if ($date) {
return $this->formatDate($date, IntlDateFormatter::MEDIUM, true);
}
return __('Never');
}
/**
* Returns customer last login date in store's timezone.
*
* @return MagentoFrameworkPhrase|string
*/
public function getStoreLastLoginDate()
{
$date = strtotime($this->getCustomerLog()->getLastLoginAt());
if ($date) {
$date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true);
return $this->formatDate($date, IntlDateFormatter::MEDIUM, true);
}
return __('Never');
}
/**
* Returns interval that shows how long customer will be considered 'Online'.
*
* @return int Interval in minutes
*/
protected function getOnlineMinutesInterval()
{
$configValue = $this->_scopeConfig->getValue(
'customer/online_customers/online_minutes_interval',
MagentoStoreModelScopeInterface::SCOPE_STORE
);
return (int)$configValue > 0 ? (int)$configValue : self::DEFAULT_ONLINE_MINUTES_INTERVAL;
}
/**
* Get customer account lock status
*
* @return MagentoFrameworkPhrase
*/
public function getAccountLock()
{
$customerModel = $this->getCustomerRegistry()->retrieve($this->getCustomerId());
$customerStatus = __('Unlocked');
if ($customerModel->isCustomerLocked()) {
$customerStatus = __('Locked');
}
return $customerStatus;
}
}

Vendor/Module/view/adminhtml/layout/customer_form.xml

<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">customer_form.customer_form_data_source</item>
</item>
<item name="label" xsi:type="string" translate="true">Customer Information</item>
<item name="reverseMetadataMerge" xsi:type="boolean">true</item>
</argument>
.
.
.
<htmlContent name="customer_edit_tab_view_content">
<block class="MagentoCustomerBlockAdminhtmlEditTabView" name="customer_edit_tab_view" template="Magento_Customer::tab/view.phtml">
<arguments>
<argument name="sort_order" xsi:type="number">10</argument>
<argument name="tab_label" xsi:type="string" translate="true">Customer View</argument>
</arguments>
<block class="Vendor_CustomerBlockAdminhtmlEditTabViewPersonalInfo" name="personal_info" template="Vendor_Customer::tab/view/personal_info.phtml"/>
</block>
</htmlContent>
.
.
.
</insertListing>
</fieldset>
</form>

Vendor/Module/view/Customer/tab/view/personal_info.phtml

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var MagentoCustomerBlockAdminhtmlEditTabViewPersonalInfo $block */
$lastLoginDateAdmin = $block->getLastLoginDate();
$lastLoginDateStore = $block->getStoreLastLoginDate();
$createDateAdmin = $block->getCreateDate();
$createDateStore = $block->getStoreCreateDate();
$allowedAddressHtmlTags = ['b', 'br', 'em', 'i', 'li', 'ol', 'p', 'strong', 'sub', 'sup', 'ul'];
?>
<div class="fieldset-wrapper customer-information">
<div class="fieldset-wrapper-title">
<span class="title"><?= $block->escapeHtml(__('Personal Information')) ?>uuuu</span>
</div>
.
.
.
.
<address>
<span style="color:red;">
<strong><?= $block->escapeHtml(__('Default Billing Address')) ?></strong><br/>
<?= $block->escapeHtml($block->getBillingAddressHtml(), $allowedAddressHtmlTags) ?>
</span>
</address>
</div>