给magento产品分类添加自定义属性

作者:Jeen 发布于:2013-4-21 20:03 Sunday 分类:工作笔记

通过数据库给分类添加自定义属性, 以 Short Description 为例,

简单记录如下 (entity_type_id 对应为 catalog_category,详细请参考数据库中其他分类属性的设置)

INSERT INTO `eav_attribute` (
`attribute_id` ,
`entity_type_id` ,
`attribute_code` ,
`attribute_model` ,
`backend_model` ,
`backend_type` ,
`backend_table` ,
`frontend_model` ,
`frontend_input` ,
`frontend_label` ,
`frontend_class` ,
`source_model` ,
`is_required` ,
`is_user_defined` ,
`default_value` ,
`is_unique` ,
`note`
)
VALUES (
NULL , '3', 'short_description', NULL , NULL , 'text', NULL , NULL ,
 'textarea', 'Short Description', NULL , NULL , '0', '0', NULL , '0', ''
);

插入后生成新属性id  121

INSERT INTO `eav_entity_attribute` (
`entity_attribute_id` ,
`entity_type_id` ,
`attribute_set_id` ,
`attribute_group_id` ,
`attribute_id` ,
`sort_order`
)
VALUES (
NULL , '3', '3', '3', '121', '4'
);

仍然使用第一个表生成的id 121

INSERT INTO `catalog_eav_attribute` (
`attribute_id` ,
`frontend_input_renderer` ,
`is_global` ,
`is_visible` ,
`is_searchable` ,
`is_filterable` ,
`is_comparable` ,
`is_visible_on_front` ,
`is_html_allowed_on_front` ,
`is_used_for_price_rules` ,
`is_filterable_in_search` ,
`used_in_product_listing` ,
`used_for_sort_by` ,
`is_configurable` ,
`apply_to` ,
`is_visible_in_advanced_search` ,
`position` ,
`is_wysiwyg_enabled` ,
`is_used_for_promo_rules`
)
VALUES (
'121', NULL , '0', '1', '1', '0', '0', '0', '0', '1', '0', '0', '0', '1', '',
 '0', '1', '1', '0'
);

调用方法 catalog/category/view.phtml 中

<?php echo $_category->getData('short_description');  ?>

标签: magento

发表评论:

©2010-2024 Jeen All Rights Reserved.Powered by emlog 京ICP备15058100号-1