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 8469021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:06:31+00:00 2026-06-10T16:06:31+00:00

Been banging my head on this for 8 hours now… I have a need

  • 0

Been banging my head on this for 8 hours now…

I have a need (or rather, my company does, being a B2B) to request extra attributes at customer registration. Of course Magento doesn’t do this natively, so we’re forced down wildly convoluted build path to make it so. I bought a module to do this, but found the code to be a hot mess (not to mention simply not working).

Whatever. I guess I’ll just roll my own.

So I found a tutorial that seemed clear and to the point. So I, spends a few minutes putting it together. And…. nothing.

Further google-fu leads me here and here for that extra hot wisdom sauce.

Here’s what I’ve got (running Magento Professional v1.11 ):

File structure:

    WACI
    - Customer
    -- etc
    --- config.xml
    -- Model
    --- Resource
    ---- Eav
    ----- Mysql4
    ------ Setup.php
    -- sql
    --- customer_setup
    ---- mysql4-install-0.1.0.php

etc/modules/WACI_All.xml

<config>
    <modules>
        <WACI_Customer>
            <active>true</active>
            <codePool>local</codePool>
        </WACI_Customer>
    </modules>
</config>

config.xml

<config>

    <modules>
        <WACI_Customer>
            <version>0.1.0</version>
        </WACI_Customer>
    </modules>

    <global>

        <fieldsets>
            <customer_account>
                <title><create>1</create><update>1</update></title>
                <phone><create>1</create><update>1</update></phone>
                <agency><create>1</create><update>1</update></agency>
                <fed_id><create>1</create><update>1</update></fed_id>
                <ubi><create>1</create><update>1</update></ubi>
            </customer_account>
        </fieldsets>

        <!--<models>
            <customer>
                <class>WACI_Customer_Model</class>
            </customer>
        </models> -->

        <resources>
            <customer_setup>
                <setup>
                    <module>WACI_Customer</module>
                    <class>WACI_Customer_Model_Resource_Eav_Mysql4_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </customer_setup>
            <customer_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </customer_write>
            <customer_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </customer_read>
        </resources>

    </global>
</config>

Setup.php

<?php

    class WACI_Customer_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
    {
        public function getDefaultEntities()
        {
            return array(
                    'customer' => array(
                        'entity_model'          => 'customer/customer',
                        'table'                 => 'customer/entity',
                        'increment_model'       => 'eav/entity_increment_numeric',
                        'increment_per_store'   => false,
                        'attribute_model'       => 'customer/attribute', 
                        'attributes' => array(
                            'title' => array(
                                'type'          => 'varchar',
                                'input'         => 'text',
                                'label'         => 'Title / Position',
                                'visible'       => true,
                                'required'      => false,
                                'position'      => 63,
                            ),
                            'phone' => array(
                                'type'          => 'varchar',
                                'input'         => 'text',
                                'label'         => 'Telephone',
                                'visible'       => true,
                                'required'      => true,
                                'position'      => 64,
                            ),
                            'agency' => array(
                                'type'          => 'varchar',
                                'input'         => 'text',
                                'label'         => 'Agency / Organization',
                                'visible'       => true,
                                'required'      => false,
                                'position'      => 65,
                            ),
                            'fed_id' => array(
                                'type'          => 'varchar',
                                'input'         => 'text',
                                'label'         => 'Fed ID',
                                'visible'       => true,
                                'required'      => false,
                                'position'      => 66,
                            ),
                            'ubi' => array(
                                'type'          => 'varchar',
                                'input'         => 'text',
                                'label'         => 'UBI',
                                'visible'       => true,
                                'required'      => false,
                                'position'      => 67,
                            ),
                        ),
                    ),
                );
        }
    }

    ?>

mysql4-install-0.1.0.php

<?php

Mage::log('Installing WACI_Customer');

// die ( echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";   );

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

$eavConfig          = Mage::getSingleton(‘eav/config’);
$attribute_title    = $eavConfig->getAttribute(‘customer’, 'title');
$attribute_phone    = $eavConfig->getAttribute(‘customer’, 'phone');
$attribute_agency   = $eavConfig->getAttribute(‘customer’, 'agency');
$attribute_fedid    = $eavConfig->getAttribute(‘customer’, 'fed_id');
$attribute_ubi      = $eavConfig->getAttribute(‘customer’, 'ubi');

// put into customer_form_attribute table so field will show in admin.
$attribute_title->setData(‘used_in_forms’, array(‘adminhtml_customer’));
$attribute_phone->setData(‘used_in_forms’, array(‘adminhtml_customer’));
$attribute_agency->setData(‘used_in_forms’, array(‘adminhtml_customer’));
$attribute_fedid->setData(‘used_in_forms’, array(‘adminhtml_customer’));
$attribute_ubi->setData(‘used_in_forms’, array(‘adminhtml_customer’));

?>

Assuming I understand it correctly, I have everything in place… but nothing, nothing and more nothing.

notably:

  • If I remove the setup class, I get a fatal error, so I think everything is in place.
  • the module shows up in admin/system/configuration/advanced/ (enabled); it is written to core_config_data
  • I ripped out all code and just used empty containers (with debug stuff) – the install script never runs; it never gets written to core_resource

Question, then is two part:

1. What is preventing my install script from running?
2. Is the logic for creating new customer attributes sound?

Assuming it is – i think getting it onto the registration page / customer account / admin account should be fairly straightforward…

… Gonna go drink beer now.

Cheers.

update


as @AlexeiYerofeyev thought, the customer name itself was the issue. Changed to CustomerAttr, and the script ran immediately.

The module then functioned about as expected, but @benmarks’s solution seems cleaner, so I rewrote to match:

config.xml

0.1.0

    <global>
        <resources>
            <customerattr_setup>
                <setup>
                    <module>WACI_CustomerAttr</module>
                    <class>Mage_Customer_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </customerattr_setup>
        </resources>
        <fieldsets>
            <customer_account>
                <title><create>1</create><update>1</update></title>
                <phone><create>1</create><update>1</update></phone>
                <agency><create>1</create><update>1</update></agency>
                <fed_id><create>1</create><update>1</update></fed_id>
                <ubi><create>1</create><update>1</update></ubi>
            </customer_account>
        </fieldsets>
    </global>
</config>

setup.php

<?php


    Mage::log('Installing WACI_CustomerAttr');

    echo 'Running Upgrade: '.get_class($this)."\n <br /> \n"; 

    //die ( 'its running' );


    $installer = $this;
    /* @var $installer Mage_Customer_Model_Entity_Setup */

    $installer->startSetup();


    $installer->addAttribute('customer','agency',
                array(
                    'type'          => 'varchar',
                    'label'         => 'Agency / Organization',
                    'input'         => 'text',
                    'required'      => false,
                    'visible'       => true,
                    'position'      => 62,
                )
            );

    $installer->addAttribute('customer','title',
                array(
                    'type'          => 'varchar',
                    'label'         => 'Title / Position',
                    'input'         => 'text',
                    'required'      => false,
                    'visible'       => true,
                    'position'      => 63,
                )
            );

    $installer->addAttribute('customer','phone',
                array(
                    'type'          => 'varchar',
                    'label'         => 'Telephone',
                    'input'         => 'text',
                    'required'      => false,
                    'visible'       => true,
                    'position'      => 64,
                )
            );


    $installer->addAttribute('customer','fed_id',
                array(
                    'type'          => 'varchar',
                    'label'         => 'Fed ID',
                    'input'         => 'text',
                    'required'      => false,
                    'visible'       => true,
                    'position'      => 65,
                )
            );


    $installer->addAttribute('customer','ubi',
                array(
                    'type'          => 'varchar',
                    'label'         => 'UBI',
                    'input'         => 'text',
                    'required'      => false,
                    'visible'       => true,
                    'position'      => 66,
                )
            );


    $attrs = array('agency','title','phone','fed_id','ubi');

    foreach ($attrs as $item) {
        $attr = Mage::getSingleton('eav/config')->getAttribute('customer', $item);
        $attr->setIsUsedInForms(array('adminhtml_customer','customer_account_edit','customer_account_create'))->save();
    }

    $installer->endSetup();

    ?>

The module (and version) gets successfully written to core_resource, and attributes are successfully getting added to eav_attribute.

I can call the field up in

theme/template/customer/form/edit.phtml

<div class="input-box">
    <label for="agency"><?php echo $this->__('Agency / Organization') ?><span class="required">*</span></label><br />
    <input type="text" name="agency" id="agency" value="<?php echo $this->htmlEscape($this->getCustomer()->getAgency()) ?>" title="<?php echo $this->__('Agency') ?>" class="required-entry input-text" />
</div>

But, unfortunately, the value is not getting written to customer_entity_varchar (which was, ultimately, what my initial script did as well.

So, I’ve got the attribute in the table, but its not getting added to the customer entity as of yet.

Seems like once I have that working, I should be able to read and write that value at will, wherever required.

Any thoughts on how I might proceed at this point?

final update


ok, got this worked out:

$attr->setData('used_in_forms', array('adminhtml_customer','customer_account_edit','customer_account_create'))->save();

instead of

$attr->setIsUsedInForms(array('adminhtml_customer','customer_account_edit','customer_account_create'))->save();

For anyone who may need the info…

Turns out the array was not getting updated in the customer_form_attribute table with the prior code.

  • 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-10T16:06:32+00:00Added an answer on June 10, 2026 at 4:06 pm

    There is a chance that your install script doesn’t run because of its setup resource name (customer_setup). Since core extension Mage_Customer has the same name of setup resource and it is already installed in core_resource table with version 1.6.2.0 or something like that, your install script with version 0.1.0 may be considered as too old and is being ignored. So you can try renaming your resource to something unique.

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

Sidebar

Related Questions

I have been banging my head on a wall with this one. I need
Been banging my head on this for a while now The problem I have
I have been banging my head for hours trying to figure out why this
i've been banging my head on this for the last hours... I have a
I've been banging my head over this issue for about 5 hours now, I'm
I have been banging my head on this one for hours and I am
I have been banging my head against this for a little while now. I
I have been banging my head against this for some time now: I want
I have been banging my head over this one for quite a while now
I've been banging my head over this for hours now... and can't seem to

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.