$installer = $this;

$attributes = array(
'region' => array(
'type' => 'int',
'input' => 'select',
'source_model' => 'evebit_catalog/entity_attribute_source_region',
'frontend_label' => 'Region',
'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'frontend_input' => 'select',
'backend_type' => 'int',
'used_in_product_listing' => true,
'is_visible_on_front' => true,
'is_required' => false,
'is_user_defined' => true,
'searchable' => true,
'filterable' => true,
'comparable' => false,
'visible_in_advanced_search'=>true,
'position' => 15,
'is_unique' => false,
)
); $productEntityId = $installer->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
$allAttributeSetIds = $installer->getAllAttributeSetIds($productEntityId); foreach($attributes as $attributeCode=>$attribute)
{
$attributeModel = Mage::getModel('catalog/resource_eav_attribute');
$attributeModel->addData($attribute);
$attributeModel->setAttributeCode($attributeCode);
$attributeModel->setEntityTypeId($productEntityId); try
{
$attributeModel->save(); }catch (Mage_Core_Exception $e)
{
Mage::logException($e);
} try
{
foreach ($allAttributeSetIds as $attributeSetId){ $generalAttributeGroup = $installer->getAttributeGroupId($productEntityId,$attributeSetId,'General');
$attributeModel->setAttributeSetId($attributeSetId);
$attributeModel->setAttributeGroupId($generalAttributeGroup);
$attributeModel->save();
} }catch (Mage_Core_Exception $e)
{
Mage::logException($e);
}
} $installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'country_of_manufacture', 'frontend_label', 'Country'); $installer->endSetup();

  

Magento1.9 add attribute to catalog product & assign to all attribute set general group的更多相关文章

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

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

  2. Optimizing Item Import Performance in Oracle Product Hub/Inventory

    APPLIES TO: Oracle Product Hub - Version 12.1.1 to 12.1.1 [Release 12.1] Oracle Inventory Management ...

  3. [转]Magento Configurable Product

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

  4. Oracle Product Hub / Product Lifecycle Management / Product Information Management / Advanced Produc

    In this Document   Goal   Solution   1. Master List showing sample code for APIs in Product Data Hub ...

  5. magento产品成功添加到购物车后跳转到不同页面 添加 add to cart 按钮

    1 添加产品到购物车成功后是跳转到购物车页面或不跳转.这个在后台可以设置 system -> configuration -> After Adding a Product Redirec ...

  6. magento添加多个产品到购物车(Add multiple products to cart )

    Step  1app\design\frontend\base\default\template\catalog\product\list.phtml<?php    $_productColl ...

  7. How to Programmatically Add/Delete Custom Options in Magento? - See more at: http://apptha.com/blog/

    In this tutorial, I would like to help out Magento developers and clients with how to programmatical ...

  8. [转]论magento1和magento2的速度性能优化问题

    本文转自:http://www.360magento.com/blog/magento-speed-up/ magento从2007年发展至今,也经历了十余年的磨练,如今也迎来了magento的换代产 ...

  9. (转)Attribute在.net编程中的应用

    Attribute在.net编程中的应用(一)Attribute的基本概念 经常有朋友问,Attribute是什么?它有什么用?好像没有这个东东程序也能运行.实际上在.Net中,Attribute是一 ...

随机推荐

  1. 【Python】Async异步等待简单例子理解

    import time def run(coroutine): try: print("") coroutine.send(None) except StopIteration a ...

  2. python xpath的基本用法

    XPath是一种在XML文档中查找信息的语言,使用路径表达式在XML文档中进行导航.学习XPath需要对XML和HTML有基本的了解. 在XPath中,有七种类型的节点:文档(根)节点.元素.属性.文 ...

  3. 集合和Iterator迭代器

    集合 集合是java中提供的一种容器,可以用来存储多个数据. 注意: ①.集合只能存放对象.比如你存一个 int 型数据 1放入集合中, 其实它是自动转换成 Integer 类后存入的,Java中每一 ...

  4. 《Python游戏编程快速上手》|百度网盘免费下载|Python基础编程

    <Python游戏编程快速上手>|百度网盘免费下载| 提取码:luy6 Python是一种高级程序设计语言,因其简洁.易读及可扩展性日渐成为程序设计领域备受推崇的语言. 本书通过编写一个个 ...

  5. JVM笔记-GC常用参数设置

    GC常用参数 -Xmn -Xms -Xmx -Xss 年轻代 最小堆 最大堆 栈空间, -Xms -Xmx 一般设置成一样大小, -XX:+UseTLAB 使用TLAB,默认打开 -XX:+Print ...

  6. PHP fputcsv() 函数

    定义和用法 fputcsv() 函数将行格式化为 CSV 并写入一个打开的文件中. 该函数返回写入字符串的长度.如果失败,则返回 FALSE. 语法 fputcsv(file,fields,seper ...

  7. MIME-TYPE 列表

    Suffixes applicable Media type and subtype(s) .3dm x-world/x-3dmf .3dmf x-world/x-3dmf .a applicatio ...

  8. 记录一次线上实施snmp

    公司要实施一个部级的项目,我们公司的提供的产品要对接下客户的一个平台监控平台,该监控平台使用snmp,我们公司的产品不支持snmp,所以由我负责在现网实施snmp,记录这次现网 一.生成编译规则 1. ...

  9. JavaScript动画实例:运动的字母特效

    已知圆的坐标方程为: X=R*SIN(θ) Y=R*COS(θ)     (0≤θ≤2π) 给定初始坐标位置(X,Y),按照圆的坐标方程,从角度angle = 0开始,每间隔angleSpeed = ...

  10. Spring学习总结(7)-AOP

    参考资料:https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html#aop 1 ...