Magento Asked by maiItsyuj on February 6, 2021
I am trying to create custom attributes in customer forms. create an account, edit account, admin forms. But every time it is not creating in database eav_attribute table. plz, give me proper solution steps.
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("customer", "cust_flat_type", array(
"type" => "varchar",
"input" => "select",
'option' => array('values' => array (
0 => 'Owner',
1 => 'Tenant',
)),
"label" => "Category Of Person",
"visible" => true,
"frontend" => "",
"backend" => "",
"required" => false,
"unique" => false,
"comment" => "Customer flat type",
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible_on_front' => true,
'used_in_forms' => array(
'customer_account_create',
'customer_account_edit',
'checkout_onepage_register',
'adminhtml_customer'
),
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "cust_flat_type");
Mage::getSingleton('eav/config')
->getAttribute('customer', "cust_flat_type")
->setData('used_in_forms', array(
'customer_account_create',
'customer_account_edit',
'checkout_onepage_register',
'adminhtml_customer'
))
->save();
$installer->endSetup();
is there any way in which I will not need to create a new phtml page for create account or other
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute("customer", "otp", array(
"type" => "varchar",
"backend" => "",
"label" => "OTP",
"input" => "text",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => "OTP"
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "otp");
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'otp',
'999' //sort_order
);
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
//$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
//$used_in_forms[]="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();
$installer->endSetup();
?>
Answered by Sairam Sigirisetty on February 6, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP