Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8428585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:05:51+00:00 2026-06-10T05:05:51+00:00

I need a dropdown attribute in category. I tried to do this in installer:

  • 0

I need a dropdown attribute in category. I tried to do this in installer:

    $installer = $this;

$installer->startSetup();

$entityTypeId = $installer->getEntityTypeId('catalog_category');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$installer->addAttribute('catalog_category', 'priority', array(
    'type' => 'varchar',
    'label' => 'Priority2',
    'input' => 'select',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible' => true,
    'required' => false,
    'user_defined' => false,
    'option' => array(
            'value' => array(
                0 => array(''),
                1 => array('normal'),
                2 => array('grouping'),
                3 => array('highlighted'),
                4 => array('trendy'),
            ),
        ),
    'default' => array(0),
));

$installer->addAttributeToGroup(
        $entityTypeId, $attributeSetId, $attributeGroupId, 'priority', '11'
);

$attributeId = $installer->getAttributeId($entityTypeId, 'priority');

$installer->run("
INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
(`entity_type_id`, `attribute_id`, `entity_id`, `value`)
    SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
        FROM `{$installer->getTable('catalog_category_entity')}`;
");

Mage::getModel('catalog/category')
        ->load(1)
        ->setImportedCatId(0)
        ->setInitialSetupFlag(true)
        ->save();

Mage::getModel('catalog/category')
        ->load(2)
        ->setImportedCatId(0)
        ->setInitialSetupFlag(true)
        ->save();

$installer->endSetup();

but it doesn’t work. Nothing shows up in Catalog->categories->Manage Categories. I can create only textfield attribute like this:

$installer->addAttribute('catalog_category', 'priority', array(
'type' => 'varchar',
'label' => 'Priority2',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',

));

Do you have any ideas?
Thx for help.

EDIT.

I also tied SQL query like this:

INSERT INTO eav_attribute (entity_type_id, attribute_code, attribute_model, backend_model, backend_type, backend_table, frontend_model, frontend_input, frontend_label, frontend_class, source_model, is_required, is_user_defined, default_value, is_unique, note) VALUES
    (9, 'priority', NULL, 'NULL', 'int', 'NULL', 'NULL', 'select', 'Priority', NULL, 'eav/entity_attribute_source_table', 1, 0, 0, 0, '');
    INSERT INTO eav_attribute_option (option_id,attribute_id,sort_order) VALUES
    (1500,282,0),
    (1501,282,1),
    (1502,282,2),
    (1503,282,3),
    (1504,282,4);
    INSERT INTO eav_attribute_option_value (value_id,option_id,store_id,value) VALUES
    (201,1500,0,''),
    (202,1501,0,'normal'),
    (203,1502,0,'grouping'),
    (204,1503,0,'highlighted'),
    (205,1504,0,'trendy');

    INSERT INTO eav_entity_attribute (entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order) VALUES
    (9, 12, 7, (SELECT atribute_id FROM eav_attribute WHERE attribute_code='priority'), 2);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:05:52+00:00Added an answer on June 10, 2026 at 5:05 am

    It’s possible using module installer:

    $installer->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'myattribute', array(
        'type' => 'varchar',
        'label' => 'My attribute',
        'source' => 'module/category_attribute_myattribute',
        'backend' => 'module/category_attribute_backend_myattribute',
        'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'input' => 'select',
        'visible' => true,
        'required' => true,
        'user_defined' => false,
        'used_in_product_listing' => false,
        'group' => 'Group name',
        'default' => Module_Catalog_Model_Category_Attribute_Myattribute::DEFAULT_Groupname,
    ));
    

    Hope it helps someone 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this dropdown. I need clone for my other dropdown lists: <select name=general>
I need to populate the dropdown and onchange of this dropdown I have to
I need to create a dropdown, which can contain 100s of options. I need
I need a textfield which has an dropdown list to select an option from
If I need to preselect a dropdown option with a certain value, I can
I need to be able to read from a dropdown box on a page
I have a dropdown. I need to bind with two field of datatable value
I need same menu like on this site http://www.salesforce.com/aloha.jsp in wordpress theme. Multilevel dropdown
I have a dropdown menu that is filled by a mysql database. I need
How to detect an event coming from the Firefox history dropdown box? I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.