Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Magento的客户注册成功事件中获取用户ID?_Magento_Events - Fatal编程技术网

如何从Magento的客户注册成功事件中获取用户ID?

如何从Magento的客户注册成功事件中获取用户ID?,magento,events,Magento,Events,我的观察员正在收听活动客户注册\u成功 当一个新用户注册一个新帐户时,我只获得会话ID,而不是用户ID。如何同时获得会话ID和用户ID 我检索已注册客户信息的方式: public function getUserReg($observer){ $session = Mage::getSingleton('core/session'); $session_id = $session->getEncryptedSessionId(); $customer_data

我的观察员正在收听活动客户注册\u成功

当一个新用户注册一个新帐户时,我只获得会话ID,而不是用户ID。如何同时获得会话ID和用户ID

我检索已注册客户信息的方式:

public function getUserReg($observer){

    $session = Mage::getSingleton('core/session');
    $session_id = $session->getEncryptedSessionId();

    $customer_data = Mage::getSingleton('customer/session')->getCustomer();
    $user_id = $customer_data->entity_id;

    Mage::log("User Registration SESSION: " . $session_id, null, 't.log');
    Mage::log("User Registration USER: " . $user_id, null, 't.log');
}

您可以在Observer中获取新创建的customer对象,如下所示:

$customer = $observer->getEvent()->getCustomer();

我可以通过向您提供的代码中添加->实体\u ID来获取用户ID。太好了。您也可以这样调用:
->getId()
<?php

namespace Vendor\Module\Observer;

use Magento\Framework\Event\ObserverInterface;

class RegisterSuccess implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $customer = $observer->getEvent()->getCustomer();
        $customerID = $customer->getId();
        $customerEmail = $customer->getEmail();
        $customerName = $customer->getFirstName();
    }
}