如何在magento地址中添加新字段


How to add a new field in address in magento

我需要在Billing&一页签出中的发货地址。

我使用以下代码在数据库中添加了一个新字段。

$installer = new Mage_Eav_Model_Entity_Setup('core_setup');    
$installer->startSetup();
$installer->addAttribute('customer_address', 'ship_email', array(
            'label'        => 'Shipping Email',
            'visible'      => 1,
            'required'     => 1,
            'position'     => 1,
        ));
$installer->endSetup();

已成功创建该字段。然后,我在账单和发货表单中添加了一个名为ship_email的新文本字段。一旦我保存了表单,电子邮件就没有保存在数据库中。

有人能指导我吗…

查看http://www.fontis.com.au/blog/magento/custom-customer-signup-attributes

向下滚动到"破解方法是在Onepage Checkout的账单地址步骤中添加"Flavor"字段。"

请注意,贡献者使用原始步骤来设置模块。您还需要根据提供的billing.html说明更改shipping.html。

客户地址记录已具有无效字段"传真"。只需在.CSV文件中将其重命名为"Email2"等即可。这将完成工作,并使您省去重新设计结账表单、测试和更多测试的精力。

我知道解决方案不是"正确的方式",但你想活下去,而不是把时间花在可以解决的问题上。

在magento中,我们可以从视图文件访问模型类。请为您的模型分配ship_email字段值。

例如

$customer=Mage::getModel('customer/customer'); // please find correct model
$customer->setship_email('your form email');
$customer->save();