Install magento attribute and set source type as category

Install magento attribute and set source type as category

$installer = $this;

$installer->startSetup();

$installer->addAttribute('catalog_product', 'category_type', array(
    'group'             => 'General',
    'label'             => 'Category',
    'note'              => '',
    'type'              => 'int',    //backend_type
    'input'             => 'select',    //frontend_input
    'frontend_class'    => '',
    'source'        => 'categoryattr/attribute_source_type',
    'backend'           => '',
    'frontend'          => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
    'required'          => true,
    'visible_on_front'  => false,
    'apply_to'          => 'simple',
    'is_configurable'   => false,
    'used_in_product_listing'    => false,
    'sort_order'        => 5,
));

$installer->endSetup();

Share this Tutorial