向“客户地址”添加字段,并将其显示在管理面板中


Adding field to Customer Address and showing it in the admin panel?

我刚刚为客户地址创建了一个属性(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();
    }
}

David,我建议你完成这篇漂亮的帖子http://www.excellencemagentoblog.com/magento-adding-custom-field-to-customer-address

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

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