给分类增加一个属性
来源:互联网 发布:linux init.d 编辑:程序博客网 时间:2024/05/21 09:57
给分类增加一个属性的步骤
1:
<?xml version="1.0"?>
<config>
<modules>
<Tw_Attribute>
<active>true</active>
<codePool>community</codePool>
</Tw_Attribute>
</modules>
</config>
2
<?xml version="1.0"?>
<config>
<modules>
<Tw_Attribute>
<version>0.0.1</version>
</Tw_Attribute>
</modules>
<global>
<resources>
<attribute_setup>
<setup>
<module>Tw_Attribute</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</attribute_setup>
<attribute_write>
<connection>
<use>core_write</use>
</connection>
</attribute_write>
<attribute_read>
<connection>
<use>core_read</use>
</connection>
</attribute_read>
</resources>
</global>
</config>
3
<?php
/**
* aheadWorks Co.
*
* NOTICE OF LICENSE
*
* This source file is subject to the EULA
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://ecommerce.aheadworks.com/LICENSE-L.txt
*
* @category AW
* @package AW_Blog
* @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
* @license http://ecommerce.aheadworks.com/LICENSE-L.txt
*/
class Tw_Attribute_Helper_Data extends Mage_Core_Helper_Abstract {
}
4
\sql\attribute_setup\mysql4-install-0.0.1.php
<?php
$installer = $this;
$installer->startSetup();
$entityTypeId = $installer->getEntityTypeId('catalog_category');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute('catalog_category', 'productimg', array(
'type' => 'varchar',
'label' => 'Product Img',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => ''
));
$installer->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'productimg',
'11' //last Magento's attribute position in General tab is 10
);
$attributeId = $installer->getAttributeId($entityTypeId, 'productimg');
$installer->run("
INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
(`entity_type_id`, `attribute_id`, `entity_id`, `value`)
SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
FROM `{$installer->getTable('catalog_category_entity')}`;
");
//this will set data of your custom attribute for root category
Mage::getModel('catalog/category')
->load(1)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
//this will set data of your custom attribute for default category
Mage::getModel('catalog/category')
->load(2)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
$installer->endSetup();
OK。
- 给分类增加一个属性
- 如何给分类增加一个属性(后台)
- 给产品增加一个过滤属性test
- iOS 分类增加属性
- 给category增加属性
- 给category增加属性
- 给category增加属性
- 给分类,订单等添加一个属性字段!!
- 给分类添加一个属性,模块sql的方式 -- magento
- 如何给magento的产品分类创建一个自定义属性?
- 如何利用运行时给系统分类添加一个属性?
- 如何给magento的产品分类创建一个自定义属性?
- OC运行时语言--如何给一个分类添加属性
- 给ironpython增加一个pythonw
- 给一个窗体增加快捷键
- 给查询增加一个序列
- 给eth0增加一个IP
- 关于分类不能增加属性的说法
- Valid signing identity not found
- LaTeX入门系列之四(LaTeX模板)
- wmsys.wm_concat( ) 常用的使用方法
- 如何搭建VC6下的SSE编译环境
- ThinkPHP中SQL调试方法
- 给分类增加一个属性
- 通过串口使用AT指令发送短消息(下)
- Delphi7语言基础20130716-4
- 检查v$instance时出现 ORA-01012: not logged on
- CI5.5-计算将整数A变为整数B需要改变的二进制位数
- 关于Tinyos安装错误问题
- 解决tomcat6.0.33 配置SSL时报“No Certificate file specified or invalid file format”异常
- POI
- mysqlreport指南