Create custom category attribute without creating module

Hi,

smart-working-hard-working

Now we are going to check, how to create an custom attribute for category without creating custom module

<?php
require_once(‘../app/Mage.php’);  // Include Mage files
Mage::app()->setCurrentStore(Mage::getModel(‘core/store’)->load(Mage_Core_Model_App::ADMIN_STORE_ID)); //Set admin store id
$installer = new Mage_Sales_Model_Mysql4_Setup;
$installer->startSetup();
$attribute  = array(
    ‘type’ => ‘text’,
    ‘label’=> ‘Short Description’,
    ‘input’ => ‘textarea’,
    ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    ‘visible’ => true,
    ‘required’ => false,
    ‘user_defined’ => true,
    ‘default’ => “”,
    ‘group’ => “General Information”  // Choose Group
);
$installer->addAttribute(‘catalog_category’, ‘short_description’, $attribute);
$installer->endSetup();

 

Advertisements

One thought on “Create custom category attribute without creating module

  1. Great Stuff.
    Refined version that even works for Magento 1.9.2.0:
    setCurrentStore(Mage::getModel(‘core/store’)->load(Mage_Core_Model_App::ADMIN_STORE_ID)); //Set admin store id
    $installer = new Mage_Sales_Model_Mysql4_Setup;
    $installer->startSetup();
    $attribute = array(
    ‘type’ => ‘varchar’,
    ‘label’=> ‘Use As Product Name’,
    ‘input’ => ‘select’,
    ‘default’ => array(0),
    ‘source’ => ‘eav/entity_attribute_source_boolean’,
    ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    ‘visible’ => true,
    ‘required’ => false,
    ‘user_defined’ => true,
    ‘default’ => ”,
    ‘position’ => 2,
    ‘group’ => ‘General Information’ // Choose Group
    );
    $installer->addAttribute(‘catalog_category’, ‘use_as_product_name’, $attribute);
    $installer->endSetup();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s