【发布时间】:2011-08-09 07:05:03
【问题描述】:
我想在单页结账过程中为送货地址添加一个新字段“custom_house_no”。
我在自定义扩展 mysql 文件“mysql4-install-0.1.0.php”中添加了以下代码
// Customer Address
$entityTypeId = $installer->getEntityTypeId('customer_address');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute('customer_address', 'custom_house_no', array(
'label' => 'Custom House No',
'input' => 'text', // Input field type textbox
'type' => 'varchar', // Store varchar data type
'frontend' => '', //frontend model
'backend' => '', //backend model
'visible' => 1, //true
'required' => 0, //false
'user_defined' => 1,
'default' => '', //default value
'searchable' => 0,
'filterable' => 0,
'comparable' => 0,
'visible_on_front' => 0,
'unique' => 0,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL
// 'class' => '',
// 'source' => 'catalog/category_attribute_source_page',
));
$installer->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'custom_house_no',
'150' //last Magento's attribute position in General tab is 140
);
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'custom_house_no');
$attribute->setData('used_in_forms', array('customer_register_address', 'customer_address_edit', 'adminhtml_customer_address')); // Setting the relation between the attribute and forms in which this attribute will be used
$attribute->save();`
我还在文件夹 MY/CustomExtension/Model/Entity/Setup.php 中创建了一个类
class MY_CustomExtension_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup {
}
我还在扩展配置文件中添加了类名。
Link to config code : @987654321@
在运输模板文件中,我添加了名称为“custom_house_no”的文本框。
属性已添加成功,并且与表单有关系,但除了“custom_house_no”字段外,所有数据都保存在数据库中。
我不知道我的代码有什么问题。
【问题讨论】:
标签: magento checkout shipping street-address