Reputation: 2336
How can i add a attribute to a category in magento ?
I have read some tutorials and they said just insert two records but that doesn't work Already changed a lot and playing with the values but still no result
After each change i have cleared the cache so that is nog the problem
I am working with magento 1.5 and flat tables
inserted the next querys and testing with the values
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
(
158,
3,
'uitslag',
NULL,
'',
'varchar',
'',
'',
'text',
'Uitslag',
'',
'',
1,
0,
'',
0,
''
);
And
INSERT INTO `eav_entity_attribute`
(
`entity_attribute_id`,
`entity_type_id`,
`attribute_set_id`,
`attribute_group_id`,
`attribute_id`,
`sort_order`
)
VALUES
(
158,
3,
3,
3,
158,
61
);
Anyone a idea ?
Thanks in advance
Upvotes: 1
Views: 3952
Reputation: 678
Try something like this:
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('category', 'uitslag', array(
'label' => 'Uitslag',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => false,
'position' => 1,
));
The simply add values to categories either through the Magento admin, or directly into the catalog_category_entity_varchar table.
Upvotes: 2