I want to add select yes/no attribute through module. I found this code from somewhere and tried but cannot add the attribute.
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute(
'catalog_category',
'my_custom_attribute',
array(
'group' => 'General Information',
'input' => 'select',
'type' => 'int',
'source' => 'eav/entity_attribute_source_boolean',
'label' => 'My Custom Attribute',
'required' => 0,
'unique' => 0,
'sort_order' => 3,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$installer->endSetup();
?>
I added this code on location /var/www/html/magento/app/code/local/Test/User/sql, where Test is my package name and User is my module name. I save the above code by the name
mysql4-install-0.1.0.php
The given below is my config file:
<?xml version="1.0"?>
<config>
<modules>
<Test_User>
<version>0.1.0</version>
</Test_User>
</modules>
<frontend>
<routers>
<user>
<use>standard</use>
<args>
<module>_User</module>
<frontName>user</frontName>
</args>
</user>
</routers>
<layout> <!-- New Section Added -->
<updates>
<user>
<file>user.xml</file> <!-- This is name of the layout file for this module -->
</user>
</updates>
</layout>
</frontend>
<global>
<blocks>
<user>
<class>Test_User_Block</class>
</user>
</blocks>
<helpers>
<user>
<class>Test_User_Helper</class>
</user>
</helpers>
</global>
<!--Added for database-->
<global>
<models>
<user>
<class>Test_User_Model</class> <!-- Location of all model class files -->
<resourceModel>user_mysql4</resourceModel> <!-- Location of resource model -->
</user>
<user_mysql4>
<class>Test_User_Model_Mysql4</class>
<entities>
<user>
<table>user</table> <!-- Actual table name in sql -->
</user>
</entities>
</user_mysql4>
</models>
<resources> <!-- These are resource setting giving access to module, read/write permission on database -->
<user_setup>
<setup>
<module>Test_User</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</user_setup>
<user_write>
<connection>
<use>core_write</use>
</connection>
</user_write>
<user_read>
<connection>
<use>core_read</use>
</connection>
</user_read>
</resources>
</global>
<!--xxxxxxxxxxxxxxxxxxxxxx-->
</config>