将字段添加到客户地址并在管理面板中显示?

时间:2013-11-27 13:57:58

标签: php magento

我刚刚为customer addressess创建了一个属性(lastname2),但是我无法在管理面板的编辑地址字段中显示它。

如下所示,我设置了used_in_forms,使其包含'adminhtml_customer_address''adminhtml_customer',但该字段仍然拒绝显示。

任何帮助都将深受赞赏。

这是我的安装程序代码:

<?php
    // update customer address user defined attributes data
    $entityAttributes = array('customer_address'=> array(
            'lastname2' =>  array(
                'store_label'=>'Apellido Materno',
                'label' => 'Apellido Materno',
                'input' => 'text',
                'type'  => 'varchar',
                //System =  False and visible true = Show in 'customer_account_create', 'customer_account_edit', 'checkout_register'
                'system'=>true,
                'visible'=>true, //Watch out!! Only visible fields get processed by the form controllers!!!
                'user_defined'=>false,
                'used_in_forms' => array('customer_account_create','customer_register_address','customer_address_edit','adminhtml_customer_address','adminhtml_customer'),
                'required' => 0,
                'position' =>69
            ),
 );


# Install Attributes
foreach($entityAttributes as $entity=>$attributes)
{
    foreach($attributes as $attribute_code=>$definition)
    {
        $installer->addAttribute($entity, $attribute_code,  $definition); 

        /**
        * @var Mage_Eav_Model_Config
        */
        Mage::getSingleton('eav/config')
        ->getAttribute($entity, $attribute_code)
        ->setData('used_in_forms',$definition['used_in_forms'])
        ->save();
    }
}

2 个答案:

答案 0 :(得分:2)

大卫,我建议你完成这篇不错的帖子http://www.excellencemagentoblog.com/magento-adding-custom-field-to-customer-address

我觉得您可能还需要更改地址显示格式。

答案 1 :(得分:0)

我刚解决了。这是一个愚蠢的错误。这是将system从true更改为false的问题。

相关问题