Add Telephone to customer registration,customer edit page etc. run following setup script from magento root.
<?php
require_once('app/Mage.php');
umask(0);
Mage::app();
$installer = new Mage_Customer_Model_Entity_Setup('core_setup');
$installer->startSetup();
$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
$vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);
$installer->addAttribute('customer', 'cust_telephone', array(
'label' => 'Customer Telephone',
'input' => 'text',
'type' => 'varchar',
'forms' => array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'),
'required' => 0,
'user_defined' => 1,
));
$installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'mobile', 0);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'cust_telephone');
$oAttribute->setData('used_in_forms', array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'));
$oAttribute->save();
$installer->endSetup();
?>
Run this Script, it will add attribute "cust_telephone" and now you can use this attribute in the register form, like this
<li class="fields">
<div class="field">
<label><em>*</em><?php echo $this->__('Customer Telephone') ?></label>
<div class="input-box">
<input type="text" name="cust_telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getCust_Telephone()) ?>" title="<?php echo $this->__('Customer Telephone') ?>" class="input-text" />
</div>
</div>
</li>
the code is tested, will work 100% ;)
Alternative solution:
Delete: use Magento\Framework\App\TemplateTypesInterface;
Change TemplateTypesInterface::TYPE_HTML to self::TYPE_HTML
<?php
declare(strict_types=1);
namespace Vendor\Module\Model;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
class InstallerBase implements DataPatchInterface, PatchRevertableInterface
{
...
public function __construct(
...
) {
...
}
public function save($subjectHTML)
{
$template->load($templateName, 'template_code');
$template->setTemplateSubject($subjectHTML)
...
->setTemplateType(self::TYPE_HTML);
return $template->save();
}
Best Answer
There is a comment in \Magento\Framework\Registry that states:
Note that these deprecations warnings were added Mar 24, 2018. There are still thousands of uses in Magento's core modules.
I can't find any "officially" recommended alternatives.
Searching the web I found:
Between the ongoing, widespread use of registry in the core and the lack of recommended alternatives, I'm not personally concerned about using it for now. By the time it is actually removed, I expect there to be thousands of alternative implementations to review.
If that isn't acceptable, I think the key section from that first link is: