$attributes = array(
'product_type' => array(
'type' => 'int',
'input' => 'select',
'source_model' => 'mcatalog/source_eav_attribute_product_type',
'frontend_label' => '产品类型',
'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'frontend_input' => 'select',
'backend_type' => 'int',
'used_in_product_listing' => false,
'is_visible_on_front' => false,
'is_required' => true,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'position' => 15,
'is_unique' => false,
)
); $productEntityId = $installer->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
$productAttributeSets = Mage::getModel('eav/entity_attribute_set')->getCollection()
->addFieldToFilter('entity_type_id', $productEntityId); foreach($attributes as $attributeCode=>$attribute)
{
try{ $attributeModel = Mage::getModel('catalog/resource_eav_attribute');
$attributeModel->addData($attribute);
$attributeModel->setAttributeCode($attributeCode);
$attributeModel->setEntityTypeId($productEntityId);
$re = $attributeModel->save(); foreach ($productAttributeSets as $attributeSet){ $generalAttributeGroupId = $installer->getAttributeGroupId($productEntityId,$attributeSet->getId(),'General');
Mage::getModel('eav/entity_attribute')
->setAttributeSetId($attributeSet->getId())
->setAttributeGroupId($generalAttributeGroupId)
->setEntityTypeId($productEntityId)
->setAttributeId($re->getId())
->save();
} }catch (Exception $e){ Mage::logException($e);
} }

  

最新文章

  1. c/c++ 缓冲区的刷新
  2. HTTP参数中Etag的重要性
  3. SharePoint 中关于event receivers的讨论
  4. Web 在线文件管理器学习笔记与总结(6)jQuery UI 预览图片
  5. jdk的动态代理
  6. RAC的负载均衡有2种方式
  7. union以及一些扩展
  8. 如何使用Android中的OpenGL ES媒体效果
  9. git生成sshkey
  10. Sprite/MovieClip的Enter_Frame事件,不受addChild/removeChild影响
  11. C# Winform打包部署时添加注册表信息实现开机自启动
  12. 对python pickle的理解
  13. RxJava2学习笔记(2)
  14. 深入理解C++中public、protected及private用法
  15. linux apidoc的安装和使用
  16. send和sendmsg性能测试
  17. SET ANSI_NULLS ON,SET NOCOUNT ON,SET QUOTED_IDENTIFIER ON
  18. hadoop HA sshfen切换隔离时无法跳转ssh: bash: fuser: 未找到命令
  19. go语言基础之函数只有一个返回值
  20. UNIQLO

热门文章

  1. sscanf,sprintf(思修课的收获)
  2. 微服务迁移记(五):WEB层搭建(1)
  3. 字典内置函数&方法
  4. PHP image_type_to_extension - 获取图片后缀
  5. PHP levenshtein() 函数
  6. AtCoder Beginner Contest 173 E Multiplication 4 分类讨论 贪心
  7. Docker技术入门与实战第2版-高清文字版
  8. docker安装gitlab并部署CICD
  9. 8、Builder 建造者模式 组装复杂的实例 创造型模式
  10. Go 中的动态作用域变量