$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. Raid0,1,5,10,50

    raid0 就是把多个硬盘合并成1个逻辑盘使用,数据读写时对各硬盘同时操作,不同硬盘写入不同数据,速度快. **最少需要2块硬盘 raid1 同时对2个硬盘读写(同样的数据).强调数据的安全性.损坏一 ...

  2. SpringMV学习之拦截器的简单使用

    一.拦截器介绍 我们知道SpringMVC的拦截器(Interceptor)非常重要,尤其在Web应用中使用非常广泛,其功能类似于过滤器,用于拦截用户请求并作相应的处理.我们使用比较多的场景是系统登陆 ...

  3. PHP exit() 函数

    实例 输出一条消息,并退出当前脚本: <?php$site = "http://www.w3cschool.cc/";fopen($site,"r")or ...

  4. 牛客挑战赛 39 牛牛与序列 隔板法 容斥 dp

    LINK:牛牛与序列 (牛客div1的E题怎么这么水... 还没D难. 定义一个序列合法 当且仅当存在一个位置i满足 $a_i>a_,a_j<a_$且对于所有的位置i,$1 \leq a_ ...

  5. 发送ajax请求时候注意的问题

    1.在发送ajax请求一般都是默认为异步,就是不去等待后台响应直接可以继续发送, 但这样会有时候遇到一些问题,无法获得后台的响应参数, 所以在你打开编辑弹出框完成数据编辑后无法刷新页面, 这时候可能存 ...

  6. 如何在Spring异步调用中传递上下文

    以下文章来源于aoho求索 ,作者aoho 1. 什么是异步调用? 异步调用是相对于同步调用而言的,同步调用是指程序按预定顺序一步步执行,每一步必须等到上一步执行完后才能执行,异步调用则无需等待上一步 ...

  7. 在图像中隐藏数据:用 Python 来实现图像隐写术

    什么是“隐写术”? 隐写术是将机密信息隐藏在更大的信息中,使别人无法知道隐藏信息的存在以及隐藏信息内容的过程.隐写术的目的是保证双方之间的机密交流.与隐藏机密信息内容的密码学不同,隐写术隐瞒了传达消息 ...

  8. vue 项目运行报错

    'vue-cli-service' 不是内部或外部命令,也不是可运行的程序 或批处理文件. 运行Vue项目文件的时候报如下错误 需要先用淘宝镜像来运行:cnpm install 然后运行成功后 就可以 ...

  9. Java基础—封装

    封装是面向对象的核心特征之一,它提供了一种信息隐藏技术.类的包装包含两层含义:一是将数据和对数据的操作组合起来构成类,类是一个不可分割的独立单位:二是类中既要提供与外部联系的接口,又要尽可能隐藏类的实 ...

  10. Linux中C++提示‘close’ was not declared

    C++socket编程时关闭socket和epoll时出现‘close’ was not declared,是程序头文件缺失导致的.缺失头文件#include <unistd.h>