I have created a custom attribute "test_emails" by as following Store-->Store Attributes-->Add new Attribute, I put attribute code "test_emails" , that appeared in table "eav_attribute" and the field values in "customer_address_entity_text" as shown in Pic, Where 668 is attribute id form table "eav_attribute" for "test_emails", how can I get these values
-
need get in customer address model?– AbdulCommented Nov 24, 2015 at 12:13
-
Can you see the attribute in admin ? Looks like you have used some extension to create customer attribute.– PrateekCommented Nov 24, 2015 at 12:22
-
@Abdul"need get in customer address model? " what do you meant?, I am new to magento, can you guide me?– Abdul GhaffarCommented Nov 24, 2015 at 12:26
-
@Prateek yes I can see them in Customer-->Manage Customer-->Customer Information-->Address– Abdul GhaffarCommented Nov 24, 2015 at 12:29
-
Currently I have two address for Single customer, due to this you can see two rows In pic entity_id (3663,2557) are address id's for that user– Abdul GhaffarCommented Nov 24, 2015 at 12:33
|
Show 9 more comments
1 Answer
Add bellow code in php file(abc.php) on magento root folder and run in browser and see admin side Customer-->Manage Customer-->Customer Information-->Address,
<?php
require_once('app/Mage.php');
Mage::app('default');
class ABDUL
{
public function index()
{
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $installer->getEntityTypeId('customer_address');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute('customer_address', 'company_name', array(
'input' => 'text',
'type' => 'varchar',
'label' => 'Company Name',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
));
$installer->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'company_name',
'22' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'company_name');
$oAttribute->setData('used_in_forms', array('adminhtml_customer_address','customer_address_edit','customer_register_address'));
$oAttribute->save();
$installer->endSetup();
echo "Customer address attribute has been created successfully";
}
}
$obj = new ABDUL();
$obj->index();
?>
-
-
I need to read the value, not to crate the new attribute Commented Nov 24, 2015 at 13:24