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

how do i alter customer dataset
 
__pete®
Jr. Member
 
Total Posts:  11
Joined:  2007-11-22
 

hey there,

it should be nothing complicated needed here:

we want customers have new fields - we found out how to get varchar fields work -> they will view in frontend and backend but if we add a field type text -> textarea

$customer->getAttributes() will not retrieve this new field in attributes :\ whats wrong with texts?also integer was a bit wrong / is_active as value of the core dataset could not be altered without much codechanges…

here in short how we add a new field:

* alter table eav_attribute
o search for some other attributes with entity_type_id = 1
o copy one of these lines and alter the name and the things you want “new”
* add a Mage_Customer_Model_Entity_Customer_Attribute_… class like described in backend_model in your new datarow
* Mage_Customer_Model_Entity_Setup altering (function getDefaultEntities -> alter the long array with your new field)
* Mage_Customer_Model_Mysql4_Customer - _prepareSaveData() - add $data[’yourfield’] = ... like the others
* alter Html Templates: customer/form/edit.phtml and customer/form/register.phtml

what at least to do to get a textarea also appear in the admin customer backend? wink
thx for advises.
_pete®

 
Magento Community Magento Community
Magento Community
Magento Community
 
__pete®
Jr. Member
 
Total Posts:  11
Joined:  2007-11-22
 

workarround for now is this horror:

Mage_Adminhtml_Block_Customer_Edit_Tab_Account - initForm…

$collection Mage::getResourceModel('customer/customer_collection')
                ->
addAttributeToSelect('description')
                ->
addAttributeToFilter('email'$customer->getData('email'))
                ->
setPage(1,1);
        
$collection->load();
        
        foreach (
$collection->getItems() as $item{
            $customer
->setDescription($item->getData('description'));
        
}
$fieldset
->addField('description','textarea',array(
                    
'label' => __('Description'),
                    
'name'    =>'description',
                    
'class' => '',
                    
'value' => $customer->getDescription()
                )
            )->
setEntityAttribute($customer->getAttribute('description'));

_pete®

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