1

I studied regarding how to add new field in registration form for new customer. Got to know that need to add attribute for it. I created a module for it. But now, admin add new customer page shows me this error.

There has been an error processing your request Exception printing is disabled by default for security reasons. Error log record number: 168844915537

My module code is as follows: app/etc/modules/Addattribute_Customer.xml

<?xml version="1.0"?>
    <config>
        <modules>
            <Addattribute_Customer>
                <active>true</active>
                <codePool>local</codePool>
                <depends><Mage_Customer/></depends>
            </Addattribute_Customer>
        </modules>
    </config>

app/code/local/Addattribute/Customer/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Addattribute_Customer>
            <version>1.0.0</version>
        </Addattribute_Customer>
    </modules>

    <global>
        <helpers>
            <addattribute_customer>
                <class>Addattribute_Customer_Helper</class>
            </addattribute_customer>
        </helpers>

        <resources>
            <addattribute_customer_setup>
                <setup>
                    <module>Addattribute_Customer</module>
                    <class>Mage_Customer_Model_Resource_Setup</class>
                </setup>
            </addattribute_customer_setup>
        </resources>
    </global>
    <frontend>
        <layout>
            <updates>
                <addattribute_customer>
                    <file>addattribute_customer.xml</file>
                </addattribute_customer>
            </updates>
        </layout>
        <translate>
            <modules>
                <Addattribute_Customer>
                    <files>
                        <default>Addattribute_Customer.csv</default>
                    </files>
                </Addattribute_Customer>
            </modules>
        </translate>
    </frontend>
</config>

app/code/local/Addattribute/Customer/sql/addattribute_customer_setup/install-1.0.0.php

<?php
$installer = $this;
$installer->startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$setup->addAttribute('customer', 'sales_executive', array(
    'type'      => 'varchar',
    'label'     => 'Sales_Executive',
    'input'     => 'select',
    'position'  => 120,
    'required'  => true,//or true
    //'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'sales_executive');
$attribute->setData('used_in_forms', array(
    'adminhtml_customer',
    'checkout_register',
    'customer_account_create',
    'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();

$installer->endSetup();
?>

app/code/local/Addattribute/Customer/Helper/Data.php

<?php
class Addattribute_Customer_Helper_Data extends Mage_Core_Helper_Abstract
{

}

Please give your suggestion or mark my mistake.

  • provide var/report/168844915537 file – Gopal Patel Dec 7 '16 at 7:45
  • "Source model "" not found for attribute "sales_executive"";i:1;s:3340:"#0 /home/kazim_noorani/htdocs/magento/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php(387): Mage::exception('Mage_Eav', 'Source model ""...') @GopalPatel – Kazim Noorani Dec 7 '16 at 8:16
1

Use this

<class>Mage_Customer_Model_Entity_Setup</class> 

in config.xml instead of

<class>Mage_Customer_Model_Resource_Setup</class>

In app/code/local/Addattribute/Customer/sql/addattribute_customer_setup/install-1.0.0.php

<?php
$installer = $this;
$installer->startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$installer->addAttribute('customer', 'sales_executive', array(
    'type'      => 'varchar',
    'label'     => 'Sales_Executive',
    'input'     => 'text',
    "visible"  => true,
    'required'  => true,//or true
    //'is_system' => 0,
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'sales_executive');
$attribute->setData('used_in_forms', array(
    'adminhtml_customer',
    'checkout_register',
    'customer_account_create',
    'customer_account_edit',
));
$attribute->setData('is_user_defined', 0);
$attribute->save();

$installer->endSetup();
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.