如何在magento中检索受保护的Data数组值

时间:2015-01-23 11:22:43

标签: arrays magento

我从这个

获得受保护的数组
$user_id = Mage::getSingleton('admin/session')->getData('user');
        var_dump($user_id);die;

object(Mage_Admin_Model_User)[115]
  protected '_eventPrefix' => string 'admin_user' (length=10)
  protected '_role' => null
  protected '_hasAvailableResources' => boolean true
  protected '_eventObject' => string 'object' (length=6)
  protected '_resourceName' => string 'admin/user' (length=10)
  protected '_resource' => null
  protected '_resourceCollectionName' => string 'admin/user_collection' (length=21)
  protected '_cacheTag' => boolean false
  protected '_dataSaveAllowed' => boolean true
  protected '_isObjectNew' => null
  protected '_data' => 
    array (size=17)
      'user_id' => string '1' (length=1)

我想获得'user_id'。并尝试$id = $user_id['_data']['user_id'];,但它返回null

1 个答案:

答案 0 :(得分:2)

尝试以下

$userId = Mage::getSingleton('admin/session')->getUser()->getId();

$userData = Mage::getSingleton('admin/session')->getUser()->getData();
$userId = $userData['user_id'];