1.add new product attribute
<?php //增加一个是否预售的属性,到所有商品 $installer = $this; /* @var $installer Mage_Core_Model_Resource_Setup */ $installer->startSetup(); $objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup'); //添加jd URL $attrCode = 'jd_url'; $label = 'JD Url'; $attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $attrCode); if ($attrIdTest === false) { $this->addAttribute( Mage_Catalog_Model_Product::ENTITY, $attrCode, array( 'sort_order' => 8, 'type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => $label, 'input' => 'text', 'source' => 'eav/entity_attribute_source_table', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'visible_in_advanced_search' => false, 'used_in_product_listing' => true, 'used_for_promo_rules'=>false, 'unique' => false, ) ); } //添加AMAZON URL $attrCode = 'amazon_url'; $label = 'Amazon Url'; $attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $attrCode); if ($attrIdTest === false) { $this->addAttribute( Mage_Catalog_Model_Product::ENTITY, $attrCode, array( 'sort_order' => 9, 'type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => $label, 'input' => 'text', 'source' => 'eav/entity_attribute_source_table', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'visible_in_advanced_search' => false, 'used_in_product_listing' => true, 'used_for_promo_rules'=>false , 'unique' => false, ) ); } $installer->endSetup();
2. add attribute group and append new attribute to it.
<?php //增加一个是否预售的属性,到所有商品 $installer = $this; /* @var $installer Mage_Core_Model_Resource_Setup */ $installer->startSetup(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); //$attribute_set_name = 'your attribute set name here'; $group_name = 'External Website Link'; $attribute_code_arr = array('jd_url', 'amazon_url'); //add group to all attribute set //get the type ID of the product - you will need it later $entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId(); //get all attribute sets $sets = Mage::getModel('eav/entity_attribute_set') ->getResourceCollection() //filter only sets for products - that's why you needed the product type ID ->addFilter('entity_type_id', $entityTypeId); //loop through all the sets foreach ($sets as $set){ //create an attribute group instance $modelGroup = Mage::getModel('eav/entity_attribute_group'); //set the group name $modelGroup->setAttributeGroupName($group_name) //change group name //link to the current set ->setAttributeSetId($set->getId()) //set the order in the set ->setSortOrder(100); //save the new group $modelGroup->save(); } $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->load(); foreach ($attributeSetCollection as $id=>$attributeSet) { $attribute_set_name = $attributeSet->getAttributeSetName(); foreach ($attribute_code_arr as $attribute_code) { $attribute_set_id=$setup->getAttributeSetId('catalog_product', $attribute_set_name); $attribute_group_id=$setup->getAttributeGroupId('catalog_product', $attribute_set_id, $group_name); $attribute_id=$setup->getAttributeId('catalog_product', $attribute_code); $setup->addAttributeToSet('catalog_product',$attribute_set_id, $attribute_group_id, $attribute_id); } } $installer->endSetup();
相关推荐
Magento 2的Dmatthew_AttributeDescription模块这是一个Magento 2模块,它增加了向产品属性添加描述的功能。 将描述添加到可配置属性,并将其显示在您的产品视图页面上。 使用属性描述可以帮助向客户解释复杂的属性...
NULL 博文链接:https://justcoding.iteye.com/blog/2144634
此代码仅供参考没有后台管理表格1.8版本下可用 ...2.eav_attribute,eav_attribute_group,eav_attribute_set,eav_entity_attribute,eav_entity_type 每个表多一条数据。 作者网站:http://www.sharpmagento.com/
magento首页New Pro产品显示数目、列数。
You’ll start by getting a general understanding of what Magento is, why and how you should use it, and whether it is possible and feasible to migrate from an old web store to Magento 2. As you work ...
Chapter 1, Installing Magento 2 on Apache and NGINX, is a...new methods introduced in the Magento 2 framework and examples on how to create basic functions. Chapter 8, Creating Magento 2 Extensions – Ad
new methods introduced in the Magento 2 framework and examples on how to create basic functions. Chapter 8, Creating Magento 2 Extensions – Advanced, explains how to use advanced features in ...
Magento cloud - Developing and Maintaining your Cloud Project.
NULL 博文链接:https://justcoding.iteye.com/blog/1725217
5. Flush cache php bin/magento cache:flush,...To activate the module log into the Magento admin panel and navigate to Stores -> Configuration -> BelVG Extensions -> Product Tabs. General settings will...
Magento的sales模块算是模块里面关联度比较大的,checkout模块的下订单流程也写得让人一头雾水,附件里主要是用客户对象和产品sku+数量的数组生成订单的函数,内容不多,但是可是找了不少时间,希望能帮到正在攻克...
(支持的 Magento 版本 1.3、1.10 和 1.12) 脚本执行(如何使用) 此脚本采用一个参数,此参数特定于您使用的 Magento 版本。 基本语法: python product_feed.py <magneto> (Acceptable arugments --> 1.3, ...
New GUI added 10 predefined block positions on each page Ability to place any block in any position by easily changing CMS page layout Unlimited number of blocks inside each position Unlimited ...
magento数据结构分析 magento数据字典
演示地址:http://olegnax.com/product/athlete-responsive-magento-theme/livepreview/ Athlete Magento主题,兼容Magento 1.9.x, 1.8.x, 1.7.x ,特点:完全自适应(响应式布局),自定义子主题,无限颜色,完全...
magik shoes magento 模板, magento 1.7 模板
magento事件清单
Understand Magento extensions, and build your own from scratch! Overview Get a detailed insight into the structure of Magento Learn about event/observer-driven modules Get a hands-on introduction to...
如果你正在创建一个Magento的管理模块(学习创造Magento管理模块),那么你一定会被要求...解压需要密码,请前往http://www.hicoogle.com/magento-to-create-a-list-and-background-module.html查详情和获取解压密码。