给magento的分类加一个属性 大家应该都知道,在magneto的后台,产品属性是可以添加一个的,但是如果给分类加一个属性呢?

因为magento的产品表和分类表都是有很多表组成,其中有eav表,从原理上讲,他们都是可以添加的,只不过magento的后台没有给分类添加这个功能,可能是用处不大吧,有对给magneto添加一个属性感兴趣的朋友,自己翻译吧,呵呵,下面就是方法:

How to add new fields in magento e-commerce?

There is no easy method like adding product attribute for category yet. But we can achieve this by adding from database. You just need to deal with three tables in the database.

First one is: eav_attribute

Insert details as: [change as you need]

01 `attribute_id` = '' ,
02 `entity_type_id` = 9,
03 `attribute_code` = 'logo_size' ,
04 `attribute_model` = NULL,
05 `backend_model` = '' ,
06 `backend_type` = 'text' ,
07 `backend_table` = '' ,
08 `frontend_model` = '' ,
09 `frontend_input` = 'textarea' ,
10 `frontend_label` = 'Embroidery Size Options' ,
11 `frontend_class` = NULL,
12 `source_model` = '' ,
13 `is_required` = 0,
14 `is_user_defined` = 0,
15 `default_value` = '' ,
16 `is_unique` = 0,
17 `note` = ''

Note the inserted attribute_id's value and insert data on another table: eav_entity_attribute

1 `entity_attribute_id` = '' ,
2 `entity_type_id` = 9,
3 `attribute_set_id` = 12,
4 `attribute_group_id` = 7,
5 `attribute_id` = 968, [attribute_id you get from first table insert]
6 `sort_order` = 8

Now the final one: catalog_eav_attribute

01 `attribute_id` = 968, [attribute_id you get from first table insert]
02 `frontend_input_renderer` = NULL,
03 `is_global` = 0
04 `is_visible` = 1,
05 `is_searchable` = 0,
06 `is_filterable` = 0,
07 `is_comparable` = 0,
08 `is_visible_on_front` = 0,
09 `is_html_allowed_on_front` = 0,
10 `is_used_for_price_rules` = 1,
11 `is_filterable_in_search` = 0,
12 `used_in_product_listing` = 0,
13 `used_for_sort_by` = 0,
14 `is_configurable` = 1,
15 `apply_to` = '' ,
16 `is_visible_in_advanced_search` = 0,
17 `position` = 1,
18 `is_wysiwyg_enabled` = 0

Thats all you need to do to add new field in the manage category for magento e-commerce based websites.

Same as other values you can get the value of this field in the frontend template as below:

1 $this ->getCurrentCategory()->getLogoSize();

You can modify rest as your need.

 

转载请标注链接:magentowaterhttp://www.magentowater.com/blog/magento-catalog-ziduan