【问题标题】:Magento: Get Customer ID in AdminMagento:在管理员中获取客户 ID
【发布时间】:2019-09-25 13:15:14
【问题描述】:

在 Magento 1.9 中,我想在 Mage_Adminhtml_Block_Customer_Edit_Tab_View 中获取已打开客户的 customerId。

我试过这样:

$customer_session = Mage::getSingleton('customer/session'); //I saw here in Stackoverflow this
$customer = $customer_session->getCustomer();
$customerID = $customer->getId();

但我得到了一个空值。

我也尝试了$this->getId()Mage::helper('customer')->getId(),但都没有成功。

如何做到这一点?

【问题讨论】:

    标签: magento admin magento-1.9


    【解决方案1】:

    对于管理员,我们应该使用 'admin/session' 作为 'customer/session'

    $user = Mage::getSingleton('admin/session'); 
    $userId = $user->getUser()->getUserId();
    $userEmail = $user->getUser()->getEmail();
    

    【讨论】:

    • 感谢您的回答。我更新了我的问题。我正在寻找在客户管理器中打开的用户 ID
    【解决方案2】:

    我发现正确的方法是:

    $customerID = $this->getCustomer()->getId();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-24
      • 2012-02-18
      • 2013-04-15
      • 1970-01-01
      相关资源
      最近更新 更多