Can no longer add registration fields in Magento 1.4.2.0

℡╲_俬逩灬. 提交于 2019-11-26 21:43:13

问题


I have used this tutorial before for adding registration fields to the Magento registration page.

It has always worked, but since I have upgraded to Magento 1.4.2.0 it no longer does. The attributes I add no longer show up under the customers information tab in the backend like it did before and are not getting saved. The attributes install into the database fine though. I thought maybe the config.xml part had changed but I checked it against the core customer one and the attributes are sill shown the same way:

<flavour><create>1</create><update>1</update></flavour>

Something must have changed since the last 1.4.2 beta because it worked fine then. If someone has any ideas it would be greatly appreciated and I could finally get some sleep! Thanks in advance!


回答1:


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.




回答2:


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)




回答3:


try this one :

http://www.magento.cc/custom-accountregistration-fields.html




回答4:


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.



来源:https://stackoverflow.com/questions/4549112/can-no-longer-add-registration-fields-in-magento-1-4-2-0

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