0

I'm trying to get Visitor Id of customer after customer registration success, and using event customer_register_success for this purpose. But this event may called earlier I think, because if I print data from log_customer table in this event, it doesn't show me the log record for the last current customer. But record is getting added to database. please suggest the right event to do the job done.

EDIT :

Just realized that customer log is getting updated in visitor _aftersave function

if ($this->_urlLoggingCondition->isLogEnabled()) {
    $this->_saveVisitorUrl($visitor);
    if ($visitor->getDoCustomerLogin() || $visitor->getDoCustomerLogout()) {
        $this->_saveCustomerInfo($visitor);
     }
}

But its called after customer_login so can't get it through this event & none of the other event is called after that (or I haven't fount one ?)

1 Answer 1

0

If you see the customer controller createPost action you will notice that the event gets fired after successful creation of customer. The reason you are not getting customer id might be because the customer object passed in this dispatch event is same as the object this action received. That is why when you try to fetch Id you donot get the Id but are able to see the entry in db.

To resolve this problem, you can either fetch the id from customer email as below:

$customer_email = $observer->getEvent()->getCustomer()->getEmail();
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($customer_email);

Or use a postdispatch event, something like this:

Where you have to replace controller_action with the controller and action name that you want. This will basically dispatch the event after the completion of action's execution.

Hope it helps!!

1
  • let me explain, the problem is not getting the Customer Id, I can get it into customer_register_success event. The issue is I can't get Visitor Id of the customer from log_customer table in the same event, and the question is which event is fired after log_customer table update Thanks
    – Ahmed
    Nov 25, 2015 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.