1

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 enter image description here

14
  • need get in customer address model?
    – Abdul
    Commented Nov 24, 2015 at 12:13
  • Can you see the attribute in admin ? Looks like you have used some extension to create customer attribute.
    – Prateek
    Commented 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? Commented Nov 24, 2015 at 12:26
  • @Prateek yes I can see them in Customer-->Manage Customer-->Customer Information-->Address Commented 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 Commented Nov 24, 2015 at 12:33

1 Answer 1

1

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();
?>
2
  • What does this code do, Commented Nov 24, 2015 at 13:24
  • I need to read the value, not to crate the new attribute Commented Nov 24, 2015 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.