I would like to create three different category attribute, a custom input text, a wysiwyg text area, and another category image upload.
I started first on custom input text as I think the easiest but it doesn't work. I checked the core_resource to see if the version was registered but it wasn't and the attribute was not present on the category.
This is my code
app/etc/modules/Rnd_Customheader.xml
<?xml version="1.0"?>
<config>
<modules>
<Rnd_Customheader>
<active>true</active>
<codePool>community</codePool>
</Rnd_Customheader>
</modules>
</config>
app/code/local/Rnd/Customheader/etc
<?xml version="1.0"?>
<config>
<modules>
<Rnd_Customheader>
<version>0.1.0</version>
</Rnd_Customheader>
</modules>
<global>
<resources>
<Rnd_Customheader_setup>
<setup>
<module>Rnd_Customheader</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>default_setup</use>
</connection>
</Rnd_Customheader_setup>
</resources>
</global>
</config>
app/code/local/Rnd/Customheader/sql/rnd_customheader_setup
<?php
$installer = $this;
$installer->startSetup();
$attribute = array(
'type' => 'text',
'label' => 'Custom Header (If you want different page header)',
'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', 'custom_header', $attribute);
$installer->endSetup();
?>
This are my references
https://magento.stackexchange.com/questions/94833/add-custom-attribute-for-category
http://gauss-development.com/blog/tutorials/adding-custom-category-attributes-magento/
Are there missing or steps I missed?
If i'm right, this extension will run once the page refreshes?
Try the following changes:
<?xml version="1.0"?>
<config>
<modules>
<Rnd_Customheader>
<version>0.1.0</version>
</Rnd_Customheader>
</modules>
<global>
<resources>
<customheader_setup>
<setup>
<module>Rnd_Customheader</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>default_setup</use>
</connection>
</customheader_setup>
</resources>
Change Rnd_Customheader_setup to customheader_setup and rename the dircetory to app/code/local/Rnd/Customheader/sql/customheader_setup
Also make sure install script name should be mysql4-install-0.1.0.php , here 0.1.0 is your module version.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.