PauGNU
PauGNU

Reputation: 793

How to add admin user attributes in Magento

I'd like to add some new attributes to the admin users in Magento. These users are different than customers (just to make it clear) and it's only possible to set their user/name/lastname/mail/pass, but I'd like to add a few new attributes.

To do so, I guess I can use the addattribute function, but I need to find out which is the id of these admin users. For example, if I want to add a new attribute to a customer, I can use a function like this:

$setup->addAttribute('customer','attribute_id', $attr );

So, in this case, 'customer' is the id for customers. How can I find out which id is used for admin users? (this question can be extended to "How can I find the different id for the different types of attributes in Magento?").

==There is a chance that there is no way to change this. I've taken a look at the admin_user table and it's quite simple, all fields are there. So maybe there are no attributes in this case.==

Thanks

Upvotes: 2

Views: 2947

Answers (3)

Ashwani Shukla
Ashwani Shukla

Reputation: 628

You will need to add a column to the admin_user table.

$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'location', array(
    'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
    'length' => 256,
    'nullable' => true,
    'default' => null
)); 

Then, if you want to add/edit this field from the backend you need to rewrite the method Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main::_prepareForm and add a new element in there:

        $fieldset->addField('location', 'select', array(
            'name'      => 'is_active',
            'label'     => Mage::helper('adminhtml')->__('location'),
            'id'        => 'is_active',
            'title'     => Mage::helper('adminhtml')->__('location'),
            'class'     => 'input-select',
            'style'     => 'width: 80px',
            'options'   => array('1' => Mage::helper('adminhtml')->__('Yes'), '0' => Mage::helper('adminhtml')->__('No')),
        )); 

Clear the cache and it should work.

Upvotes: 1

open-ecommerce.org
open-ecommerce.org

Reputation: 1814

No option till 1.7

thats what i use in the template to show the sku to an specific user bit dirty but works fine:

<?php
  //EGS SKU added for Power User
  $_powerUser = 777;
  if (Mage::getSingleton('customer/session')->getCustomer()->getId() == $_powerUser) 
  {
   echo '<div class="price-from">' . $_product->getSku() . '</div>';
  }
?>

Upvotes: 0

vsushkov
vsushkov

Reputation: 2435

You can find all such ids (entity ids) in the eav_entity_type table. And yes, there is no record for admin user. Because all data about admin users are stored in flat tables but not in eav. So to add a new attribute to admin user, you need to add a new column in the admin_user table

Upvotes: 7

Related Questions