Sunday, January 8, 2012

Magento Adding new field in category for admin

Adding an Attribute in Product quite simple we can add through admin but adding a field(attribute) in category cannot be achieved through admin so here is the simple solution for adding the attribute in Category through Database.Open the phpmyadmin.Here we need to work on three tables.
  1. eav_attribute
  2. eav_entity_attribute
  3. catalog_eav_attribute
First query for the eav_attribute table
Insert into eav_attribute
`attribute_id` = '',
`entity_type_id` = 9,
`attribute_code` = 'new_attribute_code',
`attribute_model` = NULL,
`backend_model` = '',
`backend_type` = 'text',
`backend_table` = '',
`frontend_model` = '',
`frontend_input` = 'textarea',
`frontend_label` = 'New Attribute Name',
`frontend_class` = NULL,
`source_model` = '',
`is_required` = 0,
`is_user_defined` = 0,
`default_value` = '',
`is_unique` = 0,
`note` = ''

After insert this query it will generate attribute id that attribute id we will be using in our second query for me it generated the 963 so we are using that in second query

Second query for the  eav_entity_attribute table
Insert into eav_entity_attribute
`entity_attribute_id` = '',
`entity_type_id` = 9,
`attribute_set_id` = 12,
`attribute_group_id` = 7,
`attribute_id` = 963, [attribute_id you get from first table insert]
`sort_order` = 8

Third query for the  eav_entity_attribute table
Insert into eav_entity_attribute
`attribute_id` = 963, [attribute_id you get from first table insert]
`frontend_input_renderer` = NULL,
`is_global` = 0
`is_visible` = 1,
`is_searchable` = 0,
`is_filterable` = 0,
`is_comparable` = 0,
`is_visible_on_front` = 0,
`is_html_allowed_on_front` = 0,
`is_used_for_price_rules` = 1,
`is_filterable_in_search` = 0,
`used_in_product_listing` = 0,
`used_for_sort_by` = 0,
`is_configurable` = 1,
`apply_to` = '',
`is_visible_in_advanced_search` = 0,
`position` = 1,
`is_wysiwyg_enabled` = 0

Now You can check that attribute will be get inserted in the category

Note: We can add the Browse button image in category with the same query only need to change the   `backend_type`



2 comments:

  1. Raw SQL and Magento is just wrong

    ReplyDelete
  2. Hi,,can u tell me where it is getting wrong ?and what error you are getting?

    ReplyDelete

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...