Monday 2 March 2015

Magento category attribute with yes/no value for top navigation

Step 1:
In root folder create category_attribute.php file and run file that create yes/no attribute in catalog -> manage category section.

<?php
require_once("app/Mage.php");
Mage::app('default');

$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId     = $installer->getEntityTypeId('catalog_category');
$attributeSetId   = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$installer->addAttribute('catalog_category', 'show_in_left_navigation',  array(
    'group'    => 'General Information',
    'type'     => 'int',
    'label'    => 'Show in left navigation',
    'input'    => 'select',
    'global'   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'default'           => 0,
    'source' => 'eav/entity_attribute_source_boolean'
));
?>


Hope this help...