【问题标题】:How to add a new field in address in magento如何在magento的地址中添加一个新字段
【发布时间】:2011-06-24 12:47:18
【问题描述】:

我需要在一页结帐的账单和送货地址中添加“电子邮件”字段。

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

$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 的新文本字段。一旦我保存了表单,电子邮件就没有保存在数据库中。

谁能指导我...

【问题讨论】:

    标签: php magento customization


    【解决方案1】:

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

    向下滚动到“技巧是在 Onepage Checkout 的帐单地址步骤中添加“风味”字段。'

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

    【讨论】:

    【解决方案2】:

    客户地址记录已经有失效的“传真”字段。只需在 .CSV 文件中将其重命名为“Email2”等。这将完成工作,让您无需重新设计结帐表单、测试和更多测试。

    我知道解决方案不是“正确的方法”,但您想上线,而不是花时间解决可以解决的问题。

    【讨论】:

    【解决方案3】:

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

    例如

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多