$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. Android TV 键盘样式开发

    布局: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=& ...

  2. arcgis for js 如何用contains过滤数据

    添加全部数据 // 构建map容器 var view = new MapView({ container: 'mapId', map: map }); /******************** * ...

  3. 经验分享:一个 30 岁的人是如何转行做程序员,进入IT行业的?

    大约一年以前,我成为了一名全职开发者,我想要总结一下这一年的经验,并且和所有人分享,一个 30 多岁的人是如何进入科技行业的: 改变职业是一件吓人的事情,有时候还会成为一件危险的事情.年龄越大,危险就 ...

  4. 创建githup远程库并关联

    第一种方法:远程new仓库时直接勾选初始化仓库,然后克隆到本地即可(注:本地对应层不可再初始化仓库git init).克隆下来的仓库已经与远程库建立了管理git removte 第二种方法:本地下面有 ...

  5. Spring的事务抽象

    Spring提供了一致的事务管理抽象,该抽象能实现为不同的事务API提供一致的编程模型.无视我们使用jdbc.hibernate.mybatis哪种方式来操作数据,无视事务是jta事务还是jdbc事务 ...

  6. 深入了解Redis(1)-字符串底层实现

    一.简单动态字符串(SDS) Redis中字符串实现有两种方式,C语言传统字符串(以空字符结尾的字符数组)和简单动态字符串(SDS),并将SDS作为默认字符串表示. C字符串只会作为字符串字面量,用在 ...

  7. Ajax中关于xmlhttp.readyState的值及解释

    xmlhttp.readyState的值及解释:0:请求未初始化(还没有调用 open()).1:请求已经建立,但是还没有发送(还没有调用 send()).2:请求已发送,正在处理中(通常现在可以从响 ...

  8. asp.net core 3.1多种身份验证方案,cookie和jwt混合认证授权

    开发了一个公司内部系统,使用asp.net core 3.1.在开发用户认证授权使用的是简单的cookie认证方式,然后开发好了要写几个接口给其它系统调用数据.并且只是几个简单的接口不准备再重新部署一 ...

  9. MySQL8.0.20安装配置+用Navicat连接详细教程(win10,Navicat15)

    MySQL 是最流行的关系型数据库管理系统,在 WEB 应用方面 MySQL 是最好的 RDBMS(Relational Database Management System:关系数据库管理系统)应用 ...

  10. 迭代列表不要For循环,这是Python列表推导式最基本的概念

    如果你还在使用 For 循环迭代列表,那么你需要了解了解列表推导式,看看它的基本概念都是什么. 列表解析式(List comprehension)或者称为列表推导式,是 Python 中非常强大和优雅 ...