skip to Main Content

In Magento 1.9 I want to get the customerId of opened customer in Mage_Adminhtml_Block_Customer_Edit_Tab_View.

I tried like this:

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

But I got a null.

I also tried with $this->getId() and Mage::helper('customer')->getId(), but neither worked.

How do achieve this?

2

Answers


  1. Chosen as BEST ANSWER

    I figured out that the correct way is:

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


  2. For admin we should use ‘admin/session’ for ‘customer/session’

    $user = Mage::getSingleton('admin/session'); 
    $userId = $user->getUser()->getUserId();
    $userEmail = $user->getUser()->getEmail();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search