0

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:

<?php

$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);
$attribute->save();
?>

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.

<US>1</US>
<UK>2</UK>
0

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.

| improve this answer | |

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.