I want to add a new attribute for the customers: continent.

First of all, I have created a new module for this where I'm inserting this new attribute:


$this->addAttribute('customer', 'continent', array(
    'type'      => 'int',
    'label'     => 'Continent',
    'input'     => 'text',
    'position'  => 120,
    'required'  => true,
    'is_system' => 0,

$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'continent');
$attribute->setData('is_user_defined', 0);

There's nothing to show in the frontend, everything in the backend depending on the chosen country.

And now I want to implement the logic when a new user register or edits his personal info. Something like:

if country = US then continent = 1, if country = UK then continent = 2, and so on...

I want to kepp a static file (XML?) somewhere with the relationships between countries and continents.


1 Answer 1


Answered here: Admin customer set option_id

In your source model you can read an XML file if you want ... or you just add the continents there.

If you use varchar as type instead of int you can even write north america, south america, europe, africa, ... into the db so it is still readable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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