$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. HTTP的实体数据

      数据类型表示实体数据的内容是什么,使用的是MIME    type,相关的头字段是Accept和Content-Type:  text:即文本格式的可读数据,我们最熟悉的应该就是text/html ...

  2. intellij IDEA导入maven项目

    一.导入maven项目 1.打开intellij idea,点击File(如下图1),然后点击Open(如下图2)

  3. Spring Security 实战干货:图解用户是如何登录的

    1. 前言 欢迎阅读Spring Security 实战干货系列文章,在集成Spring Security安全框架的时候我们最先处理的可能就是根据我们项目的实际需要来定制注册登录了,尤其是Http登录 ...

  4. 96年/离职8个月/拒绝华为offer/目前自由职业-记这大半年来的挣扎与迷茫

    仅以此文,记录自己这大半年来的挣扎与迷茫. 2019 年 11 月 在公司工作七个月之后,我被裁员了. 回忆自己这七个月的经历,不管是遇到的人和事,更多感到的是收获和感恩,于是我写下了:「应届毕业生工 ...

  5. 01 . Go框架之Beego简介部署及程序流程分析

    Beego简介 beego是一个使用Go语言来开发WEB引用的GoWeb框架,该框架起始于2012年,由一位中国的程序员编写并进行公开,其目的就是为大家提供一个高效率的web应用开发框架.该框架采用模 ...

  6. 4. JSON字符串是如何被解析的?JsonParser了解一下

    公司不是你家,领导不是你妈.本文已被 https://www.yourbatman.cn 收录,里面一并有Spring技术栈.MyBatis.JVM.中间件等小而美的专栏供以免费学习.关注公众号[BA ...

  7. Java-每日学习笔记(数据库与idea技巧)

    Java杂记-2020.07.28 简单记录下今天项目用到的东西还有技术公众号学到的一些知识点 Java事务 idea编码技巧 数据库快速插入100万条数据 Java实现sql回滚 Java事务 事务 ...

  8. JavaScript 中的模块化

    JavaScript 中的模块化 最早的基于立即执行函数,闭包的模块化 const MountClickModule = function(){  let num = 0;  const handle ...

  9. PHP log() 函数

    实例 返回不同数的自然对数: <?phpecho(log(2.7183) . "<br>");echo(log(2) . "<br>&quo ...

  10. Python编程初学者指南PDF高清电子书免费下载|百度云盘

    百度云盘:Python编程初学者指南PDF高清电子书免费下载 提取码:bftd 内容简介 Python是一种解释型.面向对象.动态数据类型的高级程序设计语言.Python可以用于很多的领域,从科学计算 ...