Can no longer add registration fields in Magento 1.4.2.0

狂风中的少年 提交于 2019-11-28 00:29:12

I have been struggling with this one quite some time untill I figured it out. Since 1.4.2, the attributes to show in the admin's customer's form have to be in table customer_form_attribute.
You can add them with an upgrade in your module's setup, with this code:

$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'your_attributes_code');
$attribute->setData('used_in_forms', array('adminhtml_customer'));
$attribute->save();

Hope that helps.

Very usefull hints above, thank you David!

To make the new attributes saveable in frontend (register and edit) just expand the second parameter array of $attribute->setData like this:

$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'flavour');
$attribute->setData('used_in_forms',   array('customer_account_edit',
                                             'customer_account_create',
                                             'adminhtml_customer'));
$attribute->save();

After that you will find 3 new entries in the customer_form_attribute table instead of one.

If you want to test this before and after this change, just insert

Mage::log('attrib: '. (string)$attribute->getAttributeCode());

after line 371 in app/code/core/Mage/Customer/Model/Form.php and you will see all the used attributes in the mage system log. (valid for mage 1.4.2.0)

FYI everyone, they removed the 'special code' in community edition that shows all the custom attributes. I use enterprise and we were considering community edition due to the savings. This is one of the hurdles we will have to overcome.

Doesn't answer the question, but explains probably why they removed it from the free edition. The code to display them is completely missing from the theme.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!