0

I'm trying to add a new attribute to category management via install script. For some reason, Magento just doesn't use it.

It's a very small module (3 files)

Here's a directory tree in app/code/local:

Ageno
-----TopMarki
-------------etc
----------------config.xml
-----Model
----------Mysql4
----------------Setup.php
-----sql
--------topmarki_setup
----------------------mysql4-install-0.1.0.php

config.xml:

<config>
    <global>
        <resources>
            <topmarki_setup>
                <setup>
                    <module>Ageno_TopMarki</module>
                    <class>Ageno_TopMarki_Model_Mysql4_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>            
            </topmarki_setup>
        </resources>
    </global>

    <modules>
        <Ageno_TopMarki>
            <version>0.1.0</version>
       </Ageno_TopMarki>
    </modules>    
</config>

Setup.php:

<?php

class Ageno_TopMarki_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
{
}

mysql4-install-0.1.0.php:

$installer = $this;
$installer->startSetup();

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

$setup->addAttribute('catalog_category', 'topMarka1', array(
    'input'   => 'image',
    'type'    => 'varchar',
    'group' => 'General',
    'label'         => 'Top Marka 1',
    'visible'       => 1,
    'required'      => 0,
    'user_defined' => 1,
    'frontend_input' =>'',
    'backend' => 'catalog/category_attribute_backend_image',   
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible_on_front'  => 1,
));

$setup->addAttributeToGroup(
 $entityTypeId,
 $attributeSetId,
 $attributeGroupId,
 'topMarka1',
 '999'  //sort_order
);

$installer->endSetup();

Despite all that, there is still no new field in "Manage Categories". It should sort of install automatically, am I missing something?

EDIT: adding Ageno_TopMarki.xml to /etc/modules solved the problem. Thank you R.S

5
  • Check core_resource table if topmarki_setup entry is already there. Commented Dec 1, 2012 at 14:55
  • I have disabled caching. Commented Dec 1, 2012 at 14:55
  • Take a look at core_resources tables, does topmarki_setup exist? Commented Dec 1, 2012 at 14:56
  • Did you add the Ageno_TopMarki.xml to /etc/modules? Commented Dec 1, 2012 at 14:58
  • adding Ageno_TopMarki.xml to /etc/modules solved the problem. Thank you R.S Commented Dec 1, 2012 at 15:04

1 Answer 1

1

Try add Ageno_TopMarki.xml to /etc/modules/

<?xml version="1.0"?>
<config>
    <modules>
        <Ageno_TopMarki>
            <active>true</active>
            <codePool>local</codePool>
        </Ageno_TopMarki>
    </modules>
</config>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.