Custom attributes for categories in Magento

Sometimes there is a requirement to have custom attributes for a category, but it isn't that straightforward to add, at least not through the GUI. The method, for a text input, is:
  • 1

    Create the new attribute via admin, or via SQL using the following:
    INSERT INTO `eav_attribute` (`entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_input_renderer`, `frontend_label`, `frontend_class`, `source_model`, `is_global`, `is_visible`, `is_required`, `is_user_defined`, `default_value`, `is_searchable`, `is_filterable`, `is_comparable`, `is_visible_on_front`, `is_html_allowed_on_front`, `is_unique`, `is_visible_in_advanced_search`, `is_configurable`, `apply_to`, `position`, `note`, `is_used_for_price_rules`, `is_filterable_in_search`, `used_in_product_listing`, `used_for_sort_by`) VALUES
    (9, 'ATTRIBUTE_CODE', NULL, '', 'varchar', '', '', 'text', NULL, 'ATTRIBUTE_NAME, NULL, '', 0, 1, 0, 0, '', 0, 0, 0, 0, 0, 0, 0, 1, '', 1, ', 1, 0, 0, 0);
    
    Replace ATTRIBUTE_* with your variables.
  • 2

    Create the relationship, using the following: Replace 944 with the ID from the attribute above and 5329 with the next incremented ID in eav_entity_attribute
    INSERT INTO `eav_entity_attribute` (`entity_attribute_id`, `entity_type_id`, `attribute_set_id`, `attribute_group_id`, `attribute_id`, `sort_order`) VALUES
    (5329, 9, 12, 7, 944, 2);