Wednesday, 3 July 2013

Magento Create New Filed For Categories


Create one php file into your App folder, write the below code in that file and run this file.
Then go to Catalog -> Manage Catagory and see there your custom fields.

<?php
//    initialize magento environment for 'default' store
    require_once 'app/Mage.php';
    Mage::app('default');

    echo "initialising";
    echo runAdd();
    echo "finishing";

function runAdd()
{
    $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
    // below code will add text attribute
    $setup->addAttribute('catalog_category', 'short_description', array(
        'group'         => 'General',
        'input'         => 'textarea',
        'type'          => 'varchar',
        'label'         => 'Short Description',
        'backend'       => '',
        'visible'       => 1,
        'required'      => 0,
        'user_defined'  => 1,
        'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    ));
}

No comments:

Post a Comment

Thanks for your comments.