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

I got a simple List of ints. List<int> myInts = new List<int>(); myInts.Add(0); myInts.Add(1);
I'm currently working on a little html/js site and my current goal is to
I'm considering picking up some very rudimentary understanding of assembly. My current goal is
My goal is to extend functionality of the current asset tracking system . Basically
Edited 3.9.2011 to add one more related question Hello, I'm very new to WCF
Goal: On submission of a form to add/update/delete objects an email is sent out
Current situation: Ubuntu 8.04 server edition (live server) Postgresql 8.3.7 (from standard repositories) Postgis
Current Application Server Configuration: IIS 6.0 Windows 2003 Server Standard Edition SP2 .NET Framework
current code I've built function to do something over collection of jQuery elements: var
Current static source analysis tools for C# (or other .NET languages) usually operate on

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.