$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. spring notes

    ************************ nexus is a tool of warehouse managementfirst nexus search local warehous ,i ...

  2. Oracle数据库出现[23000][2291] ORA-02291: integrity constraint (SIMTH.SYS_C005306) violated异常

    参考链接 这个异常发生在往中间表中插入数据时,这时出现异常是因为关联的某个表没有插入数据,所以给没有插入数据的关联表插入数据,再给中间表插入数据此时异常就会解决.

  3. PHP array_udiff_assoc() 函数

    实例 比较两个数组的键名和键值(使用内建函数比较键名,使用用户自定义函数比较键值),并返回差集: <?phpfunction myfunction($a,$b){if ($a===$b){ret ...

  4. PHP is_callable() 函数

    is_callable() 函数用于检测函数在当前环境中是否可调用.高佣联盟 www.cgewang.com is_callable() 函数验证变量的内容能否作为函数调用. 这可以检查包含有效函数名 ...

  5. 二维线段树->树套树

    现在上真正的二维线段树 毕竟 刚刚那个是卡常 过题我们现在做一个更高级的做法二维线段树. 大体上维护一颗x轴线段树 然后在每个节点的下方再吊一颗维护y轴的线段树那么此时我们整个平面就被我们玩好了. 这 ...

  6. fiddler本地调试

    参考:https://blog.csdn.net/letasian/article/details/75021656 有关fiddler基础用法的介绍详见我的上一篇博客:http://www.cnbl ...

  7. doc属性__module__属性__del__(垃圾回收)__call__方法

    __module__属性: 析构函数:del 是python的垃圾回收方法,当实例运行完的时候触发,回收资源 __call__

  8. 用MPI进行分布式内存编程(1)

    <并行程序设计导论>第三章部分程序 程序3.1运行实例 #include<stdio.h> #include<string.h> #include<mpi.h ...

  9. (转)Linux 下栈溢出问题分析解决 *** stack smashing detected *** XXXX terminated

    Linux 下栈溢出问题分析解决 *** stack smashing detected *** XXXX terminated 1.利用gdb 或者valgrind 定位到具体的代码 最近在Linu ...

  10. Linux常用命令之文件查找which、find、locate命令讲解

    在之前的课程中,我们介绍了Linux系统的常用文件处理命令和权限管理命令,今天我们继续来学习Linux操作系统的其他处理命令. 1.文件搜索命令 which 命令解释 命令名称:which 命令所在路 ...