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

  • Home
  • SEARCH
  • 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 4601198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:47:28+00:00 2026-05-21T23:47:28+00:00

my current goal is to add a new customer attribute (with int type) which

  • 0

my current goal is to add a new customer attribute (with int type) which should appear as select with predefined options (loaded from a model with entries editable in backend, which is done).
I’m struggling with proper use of $installer->addAttribute() method, especially specifying correct source option. Other problem is the new attribute isn’t saved to eav_entity_attribute table

I’m on Magento CE 1.5.1.0

  • 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-05-21T23:47:28+00:00Added an answer on May 21, 2026 at 11:47 pm

    This is the code for a basic int attribute with text renderer:

    $installer = $this;
    $installer->startSetup();
    
    $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
    $setup->addAttribute('customer', 'your_attribute_code_here', array(
        'input'         => 'text',
        'type'          => 'int',
        'label'         => 'Some textual description',
        'visible'       => 1,
        'required'      => 0,
        'user_defined' => 1,
    ));
    
    $entityTypeId     = $setup->getEntityTypeId('customer');
    $attributeSetId   = $setup->getDefaultAttributeSetId($entityTypeId);
    $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
    
    $setup->addAttributeToGroup(
     $entityTypeId,
     $attributeSetId,
     $attributeGroupId,
     'your_attribute_code_here',
     '999'  //sort_order
    );
    
    $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_code_here');
    $oAttribute->setData('used_in_forms', array('adminhtml_customer'));
    $oAttribute->save();
    
    $setup->endSetup();
    

    The unusual step for adding attributes is the setData('used_in_forms') this seems to be unique to customer attributes. Without it, the field won’t get rendered, certainly not in the adminhtml anyway. You can see the valid options for this array in the customer_form_attribute database table.

    In terms of using a select with predefined options, this is what you need:

    $iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_code_here');
    $aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
    $aOption = array();
    $aOption['attribute_id'] = $iAttributeId;
    
    for($iCount=0;$iCount<sizeof($aClasses);$iCount++){
        $aOption['value']['option'.$iCount][0] = $aClasses[$iCount];
    }
    $setup->addAttributeOption($aOption);
    

    And here is a walk-through on using a custom source for your drop-down

    Hope this helps,
    JD

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

Sidebar

Related Questions

My goal is logout current session, then delete the running local user profile. And
Current, I've got a stored procedure that has a main goal of doing a
My current place of employment is currently in a transition, new ownership has taken
the goal is to retrieve the number of users in one table which have:
What is the current state of GitSharp and NGit and which one is better
//get the current member count $sql = (SELECT count(member_id) as total_members from exp_members); $result
I have the current JSON file: [{id:1,images:[{img_id:1},{img_id:2},{img_id:3}]}, [{id:2,images:[{img_id:1},{img_id:2},{img_id:3}]} How do I select the array
My current development project has two aspects to it. First, there is a public
My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)

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.