通过magento中的用户ID获取产品

时间:2011-04-21 07:03:23

标签: magento

如何获取magento管理面板的用户ID,假设我已在magento管理面板中创建了一个名为user1和user2的帐户,并授予了添加产品的权限,那么我想知道user1输入的产品以及以及user2输入了产品?

2 个答案:

答案 0 :(得分:2)

经过长时间的尝试,我得到了解决方案。 它对我有用。

 
$session = Mage::getSingleton('customer/session');
            $resource = Mage::getSingleton('core/resource');
            $read= $resource->getConnection('core_read');
            $event_attending = $resource->getTableName('event_attending');

            $select = $read->select('event_id')
                   ->from($event_attending)
                   ->where('user_id = ?',$session->getId())
                   ->order('event_date DESC') ;                
            $attending_events = $read->fetchAll($select);
            $resultArray = '';$str='';
            foreach($attending_events as $attEvent){
                if($str!='')$str.=',';              

                    $str.=$attEvent['event_id'];
            }
            //echo $str;
             $session = Mage::getSingleton('customer/session');
             if($session->isLoggedIn()){
                $events = Mage::getResourceModel('catalog/product_collection')
                             ->addAttributeToSelect('*')
                             ->addFieldToFilter('entity_id', array('in' => array($str)))
                            ->load(); 
                //print_r($events->toArray());
                return $events;
            }
            else
                return '';
   }

答案 1 :(得分:1)

$user = Mage::getSingleton('admin/session')->getData();

$userId = $user->getUser()->getUserId();
$userEmail = $user->getUser()->getEmail();
$userFirstname = $user->getUser()->getFirstname();
$userLastname = $user->getUser()->getLastname();
$userUsername = $user->getUser()->getUsername();
$userPassword = $user->getUser()->getPassword();



$adminuser = Mage::getSingleton()->getUser();
 $roleId = implode('', $adminuser->getRoles());
 $userId = $adminuser->getId();