栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

向客户实体添加属性

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

向客户实体添加属性

这是渲染器基本

int
属性的代码
text

$installer = $this;$installer->startSetup();$setup = new Mage_Eav_Model_Entity_Setup('core_setup');$setup->addAttribute('customer', 'your_attribute_pre_here', array(    'input'         => 'text',    'type'          => 'int',    'label'         => 'Some textual description',    'visible'       => 1,    'required'      => 0,    'user_defined' => 1,));$entityTypeId     = $setup->getEntityTypeId('customer');$attributeSetId   = $setup->getDefaultAttributeSetId($entityTypeId);$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);$setup->addAttributeToGroup( $entityTypeId, $attributeSetId, $attributeGroupId, 'your_attribute_pre_here', '999'  //sort_order);$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_pre_here');$oAttribute->setData('used_in_forms', array('adminhtml_customer'));$oAttribute->save();$setup->endSetup();

添加属性的不寻常步骤是,

setData('used_in_forms')
这似乎是客户属性所独有的。没有它,该字段将不会被渲染,无论如何当然不会在adminhtml中。您可以在
customer_form_attribute
数据库表中看到此数组的有效选项。

就将a

select
与预定义选项一起使用而言,这是您需要的:

$iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_pre_here');$aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');$aOption = array();$aOption['attribute_id'] = $iAttributeId;for($iCount=0;$iCount<sizeof($aClasses);$iCount++){    $aOption['value']['option'.$iCount][0] = $aClasses[$iCount];}$setup->addAttributeOption($aOption);

这里是一个步行通过使用自定义源为您的下拉

希望这对您有帮助,
京东



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/417018.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号