I'm trying to add a new attribute to category management via install script. For some reason, Magento just doesn't use it.
It's a very small module (3 files)
Here's a directory tree in app/code/local:
Ageno
-----TopMarki
-------------etc
----------------config.xml
-----Model
----------Mysql4
----------------Setup.php
-----sql
--------topmarki_setup
----------------------mysql4-install-0.1.0.php
config.xml:
<config>
<global>
<resources>
<topmarki_setup>
<setup>
<module>Ageno_TopMarki</module>
<class>Ageno_TopMarki_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</topmarki_setup>
</resources>
</global>
<modules>
<Ageno_TopMarki>
<version>0.1.0</version>
</Ageno_TopMarki>
</modules>
</config>
Setup.php:
<?php
class Ageno_TopMarki_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
{
}
mysql4-install-0.1.0.php:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('catalog_category');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('catalog_category', 'topMarka1', array(
'input' => 'image',
'type' => 'varchar',
'group' => 'General',
'label' => 'Top Marka 1',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'frontend_input' =>'',
'backend' => 'catalog/category_attribute_backend_image',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible_on_front' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'topMarka1',
'999' //sort_order
);
$installer->endSetup();
Despite all that, there is still no new field in "Manage Categories". It should sort of install automatically, am I missing something?
EDIT: adding Ageno_TopMarki.xml to /etc/modules solved the problem. Thank you R.S
core_resource
table iftopmarki_setup
entry is already there. – user487772