`
kirenenko04
  • 浏览: 152266 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

add attribute group and create new attribute to this group

 
阅读更多

//for example:

// I will add a attribute group named 'Vendor' to 'Default' attribute set

function addAttributeGroup($group_name, $attrSetName,$sort_order) {
	$modelGroup = Mage::getModel('eav/entity_attribute_group');
	$attributeSetId = Mage::getModel('eav/entity_attribute_set')
	->load($attrSetName, 'attribute_set_name')
	->getAttributeSetId();
	$modelGroup->setAttributeGroupName($group_name) //change group name
	//link to the current set
	->setAttributeSetId($attributeSetId)
	//set the order in the set
	->setSortOrder($sort_order);
	//save the new group
	$modelGroup->save();
}

addAttributeGroup('Vendor', 'Default',100);

 //Then Create a Select drop down attribute and add it to the group

function createSelectAttribute($code, $label, $group_name )
{
	$_attribute_data = array(
			'type'       => 'int',
			'input'      => 'select',
			'label'      => $label,
			'sort_order' => 1000,
			'required'   => false,
			'global'     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
			'backend'    => 'eav/entity_attribute_backend_array',
			'option'     => array (
					'values' => array(
					)
			),
			'group' => $group_name,
			'visible' => true,
			'visible_on_front'=>true,
			'unique' => false,
			'is_configurable' => false,
			'used_for_promo_rules' => true,
	);
	
	$objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
	$attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $code);
	if ($attrIdTest === false) {
		$objCatalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, $code, $_attribute_data);
	}
}

//add vendor name
createSelectAttribute('vendor_name','Vendor Name','Vendor');
//add vendor no
createSelectAttribute('vendor_no','Vendor Number','Vendor');

 //at Last i write a text format attribute function

function createTextAttribute($code, $label, $group_name )
{
	$_attribute_data = array(
			'type'       => 'varchar',
			'input'      => 'text',
			'label'      => $label,
			'required'   => false,
			'global'     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
			'backend'    => '',
			'group' => $group_name,
			'visible' => true,
			'visible_on_front'=>true,
			'unique' => false,
			'is_configurable' => false,
			'used_for_promo_rules' => true
	);
	$objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
	$attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $code);
	if ($attrIdTest === false) {
		$objCatalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, $code, $_attribute_data);
	}
}

//add vendor item no
createTextAttribute('vendor_item_no','Vendor Item Number','Vendor');

 

 

 

分享到:
评论

相关推荐

    微软数据库考试70-768: Exam Ref 70-768 Developing SQL Data Models

    Module 8: Introduction to Data Analysis [removed]DAX)This module describes how to use DAX to create measures and calculated columns in a tabular data model.Lessons DAX Fundamentals Using DAX to ...

    Dundas.Chart.for.Winform.Enterprise.v7.1.0.1812.for.VS2008

    Animation (ASP.NET Enterprise Edition only) - Version 4.0 now lets you enable charts with Flash and SVG Animation, to add a new level of presentation to your charts. With a variety of pre built ...

    WPTools.v6.29.1.Pro

    We recommend to use TMS components to create modern user interfaces, toolbars and ribbons. 19.2.2013 - WPTools 6.29.1 - fix in rtf writing code to solve problem with merged cells - fix possible range...

    Senfore_DragDrop_v4.1

    4) Add the Drag and Drop Component Suite components directory to your library path. 5) Load the demo project group: demo\dragdrop_delphi.bpg for Delphi 5 and 6 demo\dragdrop_bcb4.bpg for C++ ...

    数位板压力测试

    This specification was developed in response to a perceived need for a standardized programming inter-face to digitizing tablets, three dimensional position sensors, and other pointing devices by a ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    In particular, do not add new parameters to the end of the function just because they are new; place new input-only parameters before the output parameters. This is not a hard-and-fast rule. ...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    FastReport® VCL is an add-on component that allows your application to generate reports quickly and efficiently. FastReport® provides all the tools necessary for developing reports, including a ...

    Fast Report Enterprise v4.9.32 Full Source

    + added an ability to create multiimage TIFF files + added export headers/footers in ODF export + added ability to print/export transparent pictures (properties TfrxPictureView.Transparent and ...

    maya英文命令翻译[文].pdf

    1. Add Attribute(增加属性):允许用户为对象添加自定义属性,扩展对象的信息和功能。 2. Add Collisions(增加碰撞):用于设置物体之间的碰撞检测,使得在动态模拟中物体间能正确反应相互作用。 3. Add Emitter...

    sql and pl/sql

    - **类型转换函数**:如`TO_CHAR`、`TO_NUMBER`等,用于在不同数据类型之间转换。 - **数字(Number)格式**:用于定义数字的显示格式。 - **日期(Date)格式**:用于定义日期的显示格式。 - **NULL处理**:如`NVL`、`...

    Mysql动态更新数据库脚本的示例讲解

    IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = 'RESOURCE' AND TABLE_NAME = 'AUDIO_ATTRIBUTE' AND INDEX_NAME = 'resource_publish_resource_id_index') THEN ALTER TABLE `...

    Android下实现触摸屏上的按键.doc

    properties_kobj = kobject_create_and_add("board_properties", NULL); if (properties_kobj) ret = sysfs_create_group(properties_kobj, ``` #### 五、总结 本文详细介绍了如何在 Android 系统中实现触摸屏上...

    Oracle_11g日常操作与维护手册

    - **增加REDO日志组**: 使用命令`ALTER DATABASE ADD LOGFILE GROUP [group_name] ('[logfile_path]') SIZE [size] REUSE;`来增加REDO日志组。 - **删除日志组**: 使用命令`ALTER DATABASE DROP LOGFILE GROUP ...

    The Art of Assembly Language Programming

    3 Organization of This Text and Pedagogical Concerns 4 Obtaining Program Source Listings and Other Materials in This Text <br>Section One: Machine Organization <br>Art of Assembly ...

    Maya菜单中英文对照表

    - Add Attribute(添加属性):为对象添加可动画的属性。 - Keyframe(关键帧):设置和管理关键帧动画。 - Graph Editor(曲线编辑器):调整关键帧曲线,控制动画的运动变化。 - Time(时间):管理场景的时间...

    arcgis工具

    先选责需要另存图层的要素(直接选择或者属性表),然后在图层上右键Selection/create Layer From Selected Features。 (以前都是直接export竟然没有发现) 27.利用Hyperlinks丰富数据库,为其添加超链接。 单击...

    maya2008菜单中英文对照

    - Add Attribute (增加属性):为对象添加新的属性。 - Measure (测量):测量物体之间的距离或其他参数。 - Distance Tool (距离工具):计算两点间的距离。 - Parameter Tool (参数工具):查看和修改对象的参数。...

    Maya 菜单中英文对照

    - **添加属性(Add Attribute)**:为对象添加自定义属性。 - **测量(Measure)**:测量距离、参数或弧长等。 #### 显示(Display) - **几何体(Geometry)**:控制场景中几何体的显示方式。 - **背面(Backfaces)**:...

    maya中英对照

    - **Add Attribute (添加属性)**:为对象添加自定义属性,用于存储额外的信息或控制其行为。 - **Measure (测量)**:测量两个点之间的距离或角度,对于布局和设计很有帮助。 - **Display (显示)**:控制场景中对象的...

Global site tag (gtag.js) - Google Analytics