0

Currently in creating Admin Users we collect:

Username, First Name, Last Name, Email, Password, Password Confirmation

I would also be interested in adding Address as a field but am not sure how to do so without manually adding it to the database which would take like 10 seconds but I'm pretty sure that's not the intended way by Magento.

Could someone please walk me through the steps and what files I need to create to add this attribute to Admin Users? I've successfully created custom attributes for customers before using the following 3 files:

app/code/local/Sean/CustomerAddCustomAttr/etc/config app/code/local/Sean/CustomerAddCustomAttr/Model/Resource/Eav/Mysql4/Setup.php app/code/local/Sean/CustomerAddCustomAttr/sql/CustomerAddCustomAttr_setup/mysql4-install-0.1.0.php

So I'm familiar with how this should be done but not entirely sure how different it is from adding attributes to customers, because they have an EAV attribute table yet Admin Users don't.

Thank for reading! Hopefully you can help me out. Please leave any further questions if im unclear on anything and I'll update the question or follow up your question with a comment.

0

You are going to need to create a module which creates a new table for a simple address. If you really wanted to you could make it an EAV style table group but I think it would be overkill.

Then just add a layout update for the admin user edit which creates a new tab for the address and an observer which listens to the save event of an admin user and adds/updates the address accordingly.

| improve this answer | |
  • How would I create a table called "admin_address" then link it with the "admin_user" table? I'm not sure that I would want to make it EAV style, I think a simple address would work – CodingMageSheen Mar 24 '17 at 18:15
  • In your module's SQL setup folder you create the install (or upgrade) script to create a table of the fields you want plus a user_id column is the same data type and length of the admin_user table column user_id. IIRC it's INT(8) UNSIGNED NOT NULL. Then in your table you'd create a foreign key between your user_id field and the admin_user table's user_id field. Then in an observer, you could listen to the load_after event for the admin_user model and add your custom data to user object. – Brett Mar 24 '17 at 18:19

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.