如何在 Magento 中添加管理员用户属性

发布于 2024-11-29 04:05:40 字数 431 浏览 1 评论 0原文

我想为 Magento 中的管理员用户添加一些新属性。这些用户与客户不同(只是为了清楚起见),只能设置他们的用户/姓名/姓氏/邮件/通行证,但我想添加一些新属性。

为此,我想我可以使用 addattribute 函数,但我需要找出这些管理员用户的 id。例如,如果我想向客户添加新属性,我可以使用如下函数:

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

因此,在本例中,“customer”是客户的 id。如何找出管理员用户使用的 ID? (这个问题可以扩展到“如何在Magento中找到不同类型属性的不同id?”)。

==有可能没有办法改变这一点。我查看了 admin_user 表,它非常简单,所有字段都在那里。所以在这种情况下可能没有属性。==

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伊面 2024-12-06 04:05:40

您可以在eav_entity_type表中找到所有此类ID(实体ID)。
是的,没有管理员用户的记录。因为有关管理员用户的所有数据都存储在平面表中,而不是 eav 中。因此,要为管理员用户添加新属性,您需要在 admin_user 表中添加新列

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

随波逐流 2024-12-06 04:05:40

您需要向 admin_user 表添加一列。

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

然后,如果您想从后端添加/编辑此字段,您需要重写方法 Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main::_prepareForm 并在其中添加一个新元素:

        $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')),
        )); 

清除缓存,它应该可以工作。

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.

傲影 2024-12-06 04:05:40

在 1.7 之前没有选项,

这就是我在模板中使用的向特定用户显示 sku 的方式,有点脏,但工作正常:

<?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>';
  }
?>

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>';
  }
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文