Skip to content

Instantly share code, notes, and snippets.

@standa
Created April 30, 2015 10:02
Show Gist options
  • Save standa/fdfc87af4008b8f367f0 to your computer and use it in GitHub Desktop.
Save standa/fdfc87af4008b8f367f0 to your computer and use it in GitHub Desktop.
magento_category_attribute.php
<?php
/**
* This script creates a custom category attribute 'H1 Test'
*
* @link http://fabrizioballiano.net/2012/02/08/create-a-custom-category-attribute-in-magento/
*
* @author Standa
* @version 2015-02-12
*/
require_once '../app/Mage.php';
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = Mage::getModel('catalog/resource_eav_mysql4_setup'); //new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup;
$attribute = array(
'type' => 'text',
'label'=> 'H1 Title',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => "",
'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'h1', $attribute);
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment