This is creating a module which will update categories to include new attributes.
-
inside app/etc/modules/yourmodule.xml put the following:
<?xml version="1.0"?> <config> <modules> <Yourmodule_Sql> <active>true</active> <codePool>local</codePool> <Yourmodule_Sql> </modules> </config>
-
Next, inside app/code/local/Yourmodule/Sql/etc/config.xml put the following:
<?xml version="1.0"?> <config> <modules> <Yourmodule_Sql> <version>0.1.0</version> </Yourmodule_Sql> </modules> <global> <resources> <yourmodule_sql_setup> <setup> <module>Yourmodule_Sql</module> <class>Mage_Catalog_Model_Resource_Setup</class> </setup> </yourmodule_sql_setup> </resources> </global> </config>
-
Next, your install script here: app/code/local/Yourmodule/Sql/sql/yourmodule_sql_setup/install-0.0.1.php
<?php $this->startSetup(); $this->addAttribute('catalog_category', '[attribute code]', array( 'group' => 'General Information', 'type' => 'int', // can be int, varchar, decimal, text, datetime 'backend' => '', // If you're making an image attribute you'll need to add : catalog/category_attribute_backend_image 'frontend_input' => '', 'frontend' => '', 'label' => '[Attribute label here]', 'input' => '[attribute input here]', //text, textarea, select, file, image, multiselect 'class' => '', 'source' => '[source model for attribute]', // Only needed if using select or multiselect 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // Scope can be SCOPE_STORE, SCOPE_GLOBAL or SCOPE_WEBSITE 'visible' => true, 'frontend_class' => '', 'required' => false, // or true 'user_defined' => true, // or false 'default' => '', 'position' => 10, // Number depends on where you want it to display in the grid. )); $this->endSetup();
-
Clear cache, refresh page and it should have it installed.
Posted by Simon to Magento (2013-11-12 15:35)