0

I have created an extension following these instructions: http://www.marketingadept.com/blog/2014/01/magento-developers-add-a-custom-field-to-the-category-admin-page/ to attempt to add a field to the category admin to no avail. My field was called Custom_H1 and there is not custom_h1_setup showing up in core_resources and the line is not showing up.

Custom_H1.xml in app\etc\modules

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Custom_H1>
            <active>true</active>
            <codePool>local</codePool>
        </Custom_H1>
    </modules>
</config>

config.xml app/code/local/Custom_H1/etc/

    <?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Custom_H1>
            <!-- Make sure that the version number matches the filename on your install script! -->
            <version>0.3.0</version>
        </Custom_H1>
    </modules>
    <global>
        <resources>
            <custom_h1_setup>
                <setup>
                    <module>Custom_H1</module>
                    <!-- This next line is absolutely critical so that we call the appropriate setup class -->
                    <class>Mage_Catalog_Model_Resource_Setup</class>
                    <connection>
                        <use>core_setup</use>
                    </connection>
                </setup>
            </custom_h1_setup>
            <custom_h1_setup_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </custom_h1_setup_write>
            <custom_h1_setup_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </custom_h1_setup_read>
        </resources>
    </global>
</config>

mysql4-install-0.3.0.php in app/code/local/Custom_H1/sql/custom_h1/setup/

<?php
$installer = $this;
$installer->startSetup();

/**
* This is an entity associated with catalog_category
* @var integer
*/
$entityTypeId = $installer->getEntityTypeId('catalog_category');

/**
* Use the default attribute set for catalog_category -- this refers to the table `eav_attribute_set`
* In my case, it's 3, but this function should automatically get that for you.
* @var integer
*/
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);

/**
* This determines what group (tab) that the field will be placed. "General Information"
* is the default tab, and I'm okay with this, but see `eav_attribute_group` for other
* groups
* @var integer
*/
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

/**
* Let's set up our attribute, customize the type as needed (e.g. int, varchar, decimal)
* Note where I've used `internal_title` and change to your variable.
*/
$installer->addAttribute('catalog_category', 'custom_h1', array(
'type' => 'varchar', /* Type - see eav_entity_* for the different types */
'label' => 'Custom H1 Text', /* Your label */
'input' => 'text', /* This refers to the type of form field should display*/
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => TRUE,
'required' => FALSE,
'user_defined' => FALSE,
'default' => ''
));

/**
* Now, add the attribute to the proper attribute group - again, replace the variable title
* with yours.
*/
$installer->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'custom_h1',
'2' /* Refers to the sort order of fields - see `eav_entity_attribute` for reference on the location of other fields. I want this right below the active field, so 2 works for me.*/
);

$installer->endSetup();

I've made sure all users have all permissions to the folders these are in. How can I get this module loading and the category admin using this extra field?

NOTE: I tried going back and just making the example extension exactly as it was in the article and it still did not show an extra field. Both extensions show up in the configuration menu to enable/disable output for modules though.

1

Use app/code/local/Custom/H1 directory instead of app/code/local/Custom_H1

  • Now I just have to figure out why its getData is not working on the front end. – lathomas64 Aug 5 '14 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.