$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. ~~网络编程(三):TCP/UDP~~

    进击のpython ***** 网络编程--TCP/UDP协议 其实你也发现了,应用层是交给应用来处理的,我们什么也做不了 相较于网络编程来说,我们更重要的是在做应用层和传输层的对接 因为你也看到了, ...

  2. java基础(九)--方法重载

    如System.out.println()方法即是方法重载的. 以下举例说明自定义sum()方法的重载 package cnblogs; public class TestBase09MathRelo ...

  3. Csrf+Xss组合拳

    本文首发于“合天智汇”公众号,作者: 影子 各位大师傅,第一次在合天发文章,请多多关照 今年年初的疫情确实有点突然,打乱了上半年的所有计划(本来是校内大佬带我拿奖的时刻,没了 ,学长毕业了,就剩下我这 ...

  4. Maven中出现Could not find artifact ...:pom:0.0.1-SNAPSHOT

    参考链接:https://blog.csdn.net/zpwggi123/article/details/87189959 多模块项目构建时,先将总项目install,之后子项目分别install,注 ...

  5. 查看 __class__属性

    查看complex的__class__属性 a = 5+2j print(a.__class__) print(a.__class__.__class__) ''' <class 'comple ...

  6. python 连接 mysql 的三种驱动

    连接 mysql 驱动 mysq1-client python2,3都能直接使用 对myaq1安装有要求,必须指定位置存在 配置文件 python-mysql python3 不支持 pymysql ...

  7. PHP strtotime() 函数

    ------------恢复内容开始------------ 实例 将任何字符串的日期时间描述解析为 Unix 时间戳: <?php // 设置时区 date_default_timezone_ ...

  8. Skill 扫描list中是否含有某元素

    https://www.cnblogs.com/yeungchie/ code procedure(ycInListp(scan keylist) prog((times) times = 0 for ...

  9. 唯一约束 UNIQUE KEY

    目录 什么是唯一约束 与主键的区别 创建唯一约束 唯一性验证 什么是唯一约束 Unique Key:它是 MySQL 中的唯一约束,是指在所有记录中字段的值不能重复出现.例如,为 id 字段加上唯一性 ...

  10. 动态修改HttpServletRequest的Post请求参数

    需求场景: 公司对APP调用的后台接口有个公用格式如下,外层包含了一些设备.版本.签名信息,主要的业务参数是在body里,外层信息都是在网关解决,验证签名后,在转发body到后台服务. { " ...