0

I want to add extra column in magebto admin user, how can i add.enter image description here

I need to add phone number for the admin users how can i add?

I added like this in /app/code/core/Mage/Adminhtml/Block/Api/User/Grid.php

 <?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category Mage
 * @package Mage_Adminhtml
 * @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 */
/**
 * Adminhtml permissions user grid
 *
 * @category Mage
 * @package Mage_Adminhtml
 * @author Magento Core Team <[email protected]>
 */
class Mage_Adminhtml_Block_Api_User_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
 public function __construct()
 {
 parent::__construct();
 $this->setId('permissionsUserGrid');
 $this->setDefaultSort('username');
 $this->setDefaultDir('asc');
 $this->setUseAjax(true);
 }
 protected function _prepareCollection()
 {
 $collection = Mage::getResourceModel('api/user_collection');
 $this->setCollection($collection);
 return parent::_prepareCollection();
 }
 protected function _prepareColumns()
 {
 $this->addColumn('user_id', array(
 'header' => Mage::helper('adminhtml')->__('ID'),
 'width' => 5,
 'align' => 'right',
 'sortable' => true,
 'index' => 'user_id'
 ));
 $this->addColumn('username', array(
 'header' => Mage::helper('adminhtml')->__('User Name'),
 'index' => 'username'
 ));
 $this->addColumn('firstname', array(
 'header' => Mage::helper('adminhtml')->__('First Name'),
 'index' => 'firstname'
 ));
 $this->addColumn('lastname', array(
 'header' => Mage::helper('adminhtml')->__('Last Name'),
 'index' => 'lastname'
 ));
 $this->addColumn('email', array(
 'header' => Mage::helper('adminhtml')->__('Email'),
 'width' => 40,
 'align' => 'left',
 'index' => 'email'
 ));
 $this->addColumn('mobile', array(
 'header' => Mage::helper('adminhtml')->__('Mobile'),
 'width' => 40,
 'align' => 'left',
 'index' => 'mobile'
 ));
 $this->addColumn('is_active', array(
 'header' => Mage::helper('adminhtml')->__('Status'),
 'index' => 'is_active',
 'type' => 'options',
 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')),
 ));
 return parent::_prepareColumns();
 }
 public function getRowUrl($row)
 {
 return $this->getUrl('*/*/edit', array('user_id' => $row->getId()));
 }
 public function getGridUrl()
 {
 //$uid = $this->getRequest()->getParam('user_id');
 return $this->getUrl('*/*/roleGrid', array());
 }
}

And i added installer script in /var/www/html/app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.1-1.6.1.2.php

 <?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category Mage
 * @package Mage_Admin
 * @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 */
/** @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$table = $installer->getConnection()
 ->newTable($installer->getTable('admin/permission_variable'))
 ->addColumn('variable_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
 'identity' => true,
 'unsigned' => true,
 'nullable' => false,
 'primary' => true,
 ), 'Variable ID')
 ->addColumn('variable_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
 'primary' => true,
 'nullable' => false,
 'default' => "",
 ), 'Config Path')
 ->addColumn('is_allowed', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array(
 'nullable' => false,
 'default' => 0,
 ), 'Mark that config can be processed by filters')
 ->addIndex($installer->getIdxName('admin/permission_variable', array('variable_name'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
 array('variable_name'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
 ->setComment('System variables that can be processed via content filter');
$installer->getConnection()->createTable($table);
$installer->getConnection()->insertMultiple(
 $installer->getTable('admin/permission_variable'),
 array(
 array('variable_name' => 'trans_email/ident_support/name', 'is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_support/email','is_allowed' => 1),
 array('variable_name' => 'web/unsecure/base_url','is_allowed' => 1),
 array('variable_name' => 'web/secure/base_url','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_general/name','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_general/email', 'is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_sales/name','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_sales/email','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_custom1/name','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_custom1/email','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_custom2/name','is_allowed' => 1),
 array('variable_name' => 'trans_email/ident_custom2/email','is_allowed' => 1),
 array('variable_name' => 'general/store_information/name', 'is_allowed' => 1),
 array('variable_name' => 'general/store_information/phone','is_allowed' => 1),
 array('variable_name' => 'general/store_information/address', 'is_allowed' => 1),
 )
);
$table = $installer->getConnection()
 ->newTable($installer->getTable('admin/permission_block'))
 ->addColumn('block_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
 'identity' => true,
 'unsigned' => true,
 'nullable' => false,
 'primary' => true,
 ), 'Block ID')
 ->addColumn('block_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
 'nullable' => false,
 'default' => "",
 ), 'Block Name')
 ->addColumn('is_allowed', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array(
 'nullable' => false,
 'default' => 0,
 ), 'Mark that block can be processed by filters')
 ->addIndex($installer->getIdxName('admin/permission_block', array('block_name'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
 array('block_name'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
 ->setComment('System blocks that can be processed via content filter');
$installer->getConnection()->createTable($table);
$installer->getConnection()->insertMultiple(
 $installer->getTable('admin/permission_block'),
 array(
 array('block_name' => 'core/template', 'is_allowed' => 1),
 array('block_name' => 'catalog/product_new', 'is_allowed' => 1),
 )
);
$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'mobile', array(
 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
 'length' => 50,
 'nullable' => true,
 'default' => null
)); 
$installer->endSetup();

But it is not working.

asked Sep 23, 2020 at 16:24

1 Answer 1

1

You need to add a column in admin_user table

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

You need to overwrite this method Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main::_prepareForm and add a new element in there as below

 $fieldset->addField('phone', 'text', array(
 'name' => 'phone',
 'label' => Mage::helper('adminhtml')->__('Phone Number'),
 'title' => Mage::helper('adminhtml')->__('Phone Number'),
 'class' => 'input-text',
 )); 

before run clear the cache.

answered Sep 23, 2020 at 17:01
9
  • Thankyou, mobile column came, but no column formed in the database to store. Commented Sep 23, 2020 at 17:29
  • Can you save the data from admin panel? Commented Sep 23, 2020 at 17:31
  • @vinaysirige and if it is help to you please vote or like this post. Commented Sep 23, 2020 at 17:36
  • No mobile number column is not saving to the database Commented Sep 23, 2020 at 19:20
  • Did you use above installer script and create the database field? Commented Sep 24, 2020 at 1:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.