Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

user defined Customer Entity Attribute not visible in adminhtml [SOLVED]
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

Hi,

I added a user defined customer attribute using the code below, but it doesn’t show up in the adminhtml customer interface.
What do I have to do so I can change the value for my customers?

I placed this in the sql/ directory of my module:

<?php

$read 
Mage::getSingleton('core/resource')->getConnection('core_read');

// load id for customer entity
$eid $read->fetchRow("select entity_type_id from {$this->getTable('eav_entity_type')} where entity_type_code = 'customer'");
$customer_type_id $eid['entity_type_id'];

$installer $this;
$installer->startSetup();

// build data array for new entity attribute
$c = array(
    
'entity_type_id' => $customer_type_id,
    
'attribute_code' => 'customer_activated',
    
'backend_type' => 'int',
    
'frontend_input' => 'boolean',
    
'is_global' => 1,
    
'is_visible' => 0,
    
'is_required' => 1,
    
'is_user_defined' => 1,
);

// save attribute
$attribute = new Mage_Eav_Model_Entity_Attribute();
$attribute->loadByCode($c['entity_type_id']$c['attribute_code'])
    ->
setStoreId(0)
    ->
addData($c);
$attribute->save();

$installer->endSetup();

Thank you in advance for any pointers!
Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

My mistake!
Solution: is_visible needs to be 1

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Vinai,

Take a look at Mage_Catalog_Model_Resource_Eav_Mysql4_Setup and /magento/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-install-0.7.0.php to understand how you can package your code into a standalone module better.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

Thanks for your help,
it is much appreciated.

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top