We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

First of all, we have to create a module for adding custom category attribute.

Step 1. Create a new module.
We should let Magento know about our new module. The initial configuration file is located at ‘app/etc/modules/Namespace_Modulename.xml’.
Namespace_Modulename.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Modulename>
            <active>true</active>
            <codePool>local</codePool>
        </Namespace_Modulename>
    </modules>
</config>

Step 2.
Module configuration file is located at ‘app/code/<code_pool>/<name_space>/<module_name>/etc’ and its name is config.xml – so this path looks like ‘app/code/local/Namespace/Modulename/etc/config.xml’.

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Modulename>
            <version>1.0.0</version>
        </Namespace_Modulename>
    </modules>

    <global>
        <resources>
            <add_category_attribute>
                <setup>
                    <module>Namespace_Modulename</module>
                    <class>Mage_Catalog_Model_Resource_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </add_category_attribute>
            <add_category_attribute_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </add_category_attribute_write>
            <add_category_attribute_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </add_category_attribute_read>
        </resources>
    </global>
</config>

<add_category_attribute> presence that script must be located in the folder with the same name. ‘app/code/local/Namespace/Modulename/sql/add_category_attribute’

Step 3.
Create and install a script file in the folder ‘add_category_attribute’, and the file name depends on the module version.
mysql4-install-1.0.0.php

<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'attribute_custom', array(
    'group'         => 'General Information',
    'input'         => 'textarea',
    'type'          => 'text',
    'label'         => 'Custom attribute',
    'backend'       => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => true,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));

$this->endSetup();
?>

 

 

Fill the below form if you have any Magento programming need.

    Recent Articles
    Get a Free Quote

      Let’s initiate a discussion!!