$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);
} }

  

Magento add product attribute and assign to all group的更多相关文章

  1. [转]Magento Configurable Product

    本文转自:https://docs.magento.com/m1/ce/user_guide/catalog/product-configurable.html A configurable prod ...

  2. 向json中添加新的熟悉或对象 Add new attribute (element) to JSON object using JavaScript

    How do I add new attribute (element) to JSON object using JavaScript? JSON stands for JavaScript Obj ...

  3. enovia PLM: add characteristic to both prototype and product

    Issue: add new mandatory attribute named LUX_HazardousMaterial to protoype and product, and export t ...

  4. Magento WebServices SOAP API 创建和使用

    首先 SOAP 简介: http://baike.baidu.com/view/1695890.htm?fromtitle=SOAP 然后简单介绍下Magento API.Magento API干啥用 ...

  5. Magento创建configurable产品的要点

    接着上一篇用API创建可配置的产品Configurable Product说事.Magento的产品类型可分为Simple Product.Group Product.Configurable Pro ...

  6. Magento网站如何添加一个可配置产品

    有的产品,比如服装,同一件衣服有S.M.L.XL.XXL等尺码供客户选择,或者有多种颜色可以供客户选择,Magento中管这种有选项供客户选择的产品叫做可配置产品 (Configurable Prod ...

  7. magento搜索属性值的设置方法

    前台特性(Frontend Properties)在快速搜索中应用(Use in quick search) - 开启此选项,在客户使用Header中的 搜索功能时Magento将搜索所有产品这个At ...

  8. 将Magento后台汉化的方法

    方法一: 打开/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php文件, 找到几个用来显示的代码,替换成 ...

  9. add characteristic to color

    Problem: add a new Char. name D_COI6 that the description is Injected coloration #7 (COI6) in the D_ ...

随机推荐

  1. Python编程导论第2版|百度网盘免费下载|新手学习

    点击下方即可免费下载 百度网盘免费下载:Python编程导论第2版 提取码:18g5 豆瓣评论: 介绍: 本书基于MIT 编程思维培训讲义写成,主要目标在于帮助读者掌握并熟练使用各种计算技术,具备用计 ...

  2. Jarvisoj-web phpinfo

    题目入口:http://web.jarvisoj.com:32784/ 一进来就看到源码 简单分析之后知道考点是反序列化,注意到了关键字session_start(),这个函数是用于创建会话.但具体如 ...

  3. MyBatis Plus 导入IdType失败

    import com.baomidou.mybatisplus.annotation.IdType; 修正Entity模板IdType引入包名到com.baomidou.mybatisplus.enu ...

  4. 谁来教我渗透测试——Windows server 2003上部署动态ASP网站

    安装网站 我们点击开始/管理工具/管理您的服务器 在服务器配置页面点击添加或删除角色 选择应用程序服务器,点击下一步 将两个工具都勾选上,点击下一步 点击下一步进行安装 等待安装 安装完成后点击完成按 ...

  5. Fortify Audit Workbench Cookie Security: Cookie not Sent Over SSL

    Abstract 所创建的 cookie 的 secure 标记没有设置为 true. Explanation 现今的 Web 浏览器支持每个 cookie 的 secure 标记. 如果设置了该标记 ...

  6. pandas_使用透视表与交叉表查看业绩汇总数据

    # 使用透视表与交叉表查看业绩汇总数据 import pandas as pd import numpy as np import copy # 设置列对齐 pd.set_option("d ...

  7. PHP number_format() 函数

    实例 格式化数字: <?php高佣联盟 www.cgewang.comecho number_format("1000000")."<br>" ...

  8. Metal 线宽如何选择

    https://www.cnblogs.com/yeungchie/ Metal 线宽如何选择 假如Metal是为了传输电流,则主要需要从解决和减小它的寄生电阻.寄生电容方面多做考虑.寄生电感一般忽略 ...

  9. System.nanoTime与System.currentTimeMillis比较

    System.nanoTime与System.currentTimeMillis比较 ​currentTimeMillis返回的是系统当前时间和1970-01-01之前间隔时间的毫秒数,如果系统时间固 ...

  10. 如何在Ubuntu18.04里面添加中文输入法

    1. 安装语言包 System Settings–>Region&language->Manage installed languages–>Install/Remove L ...