I want to create an image attribute in category which maps to size chart in PDP. Following is my install script and config.xml file.
My attribute is created in eav_attribute table but it is not mapped to category table. So I get an error while saving the field. Can anyone help me with right code to create category attribute as well as save in respective category table.
config.xml
<global>
<resources>
<catalogsize_setup>
<setup>
<module>XYZ_Catalog</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
</catalogsize_setup>
</resources>
<global>
Install script
$installer = $this;
$installer->startSetup();
$attribute = array(
'type' => 'varchar',
'label'=> 'Size Chart',
'input' => 'image',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => "",
'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'size_chart', $attribute);
$installer->endSetup();
Error while saving attribute in category page back end:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'size_chart' in 'field list', query was: INSERT INTO
catalog_category_flat_store_2
(entity_id
,parent_id
,created_at
,updated_at
,path
,position
,level
,children_count
,store_id
,all_children
,available_sort_by
,children
,custom_apply_to_products
,custom_design
,custom_design_from
,custom_design_to
,custom_layout_update
,custom_use_parent_settings
,default_sort_by
,description
,display_mode
,filter_price_range
,image
,include_in_menu
,is_active
,is_anchor
,landing_page
,meta_description
,meta_keywords
,meta_title
,name
,page_layout
,path_in_store
,size_chart
,url_key
,url_path
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATEentity_id
= VALUES(entity_id
),parent_id
= VALUES(parent_id
),created_at
= VALUES(created_at
),updated_at
= VALUES(updated_at
),path
= VALUES(path
),position
= VALUES(position
),level
= VALUES(level
),children_count
= VALUES(children_count
),store_id
= VALUES(store_id
),all_children
= VALUES(all_children
),available_sort_by
= VALUES(available_sort_by
),children
= VALUES(children
),custom_apply_to_products
= VALUES(custom_apply_to_products
),custom_design
= VALUES(custom_design
),custom_design_from
= VALUES(custom_design_from
),custom_design_to
= VALUES(custom_design_to
),custom_layout_update
= VALUES(custom_layout_update
),custom_use_parent_settings
= VALUES(custom_use_parent_settings
),default_sort_by
= VALUES(default_sort_by
),description
= VALUES(description
),display_mode
= VALUES(display_mode
),filter_price_range
= VALUES(filter_price_range
),image
= VALUES(image
),include_in_menu
= VALUES(include_in_menu
),is_active
= VALUES(is_active
),is_anchor
= VALUES(is_anchor
),landing_page
= VALUES(landing_page
),meta_description
= VALUES(meta_description
),meta_keywords
= VALUES(meta_keywords
),meta_title
= VALUES(meta_title
),name
= VALUES(name
),page_layout
= VALUES(page_layout
),path_in_store
= VALUES(path_in_store
),size_chart
= VALUES(size_chart
),url_key
= VALUES(url_key
),url_path
= VALUES(url_path
)