0

What I have done:

I have few custom calculations to be done after placing an order for the customer in magento admin panel. I have hooked on to sales_order_save_after event inside tab inside my module's config.xml .

The Problem:

I need to get the customer_id of the actual customer for whom the order is been placed on the backend. How can this be done?

$_customer = Mage::getSingleton('customer/session')->getCustomer();
$customer_id=$_customer->getId(); 

The above will give me the customer_id in case of front end, I need a way to get the customer's id when ordering from backend.

In case, the event "adminhtml_sales_order_create_process_data", is what I need to hook on, do let me know. because I am also kind of confused about which event to hook on.

Help me out.

  • Try $order->getCustomer() and reply here if it worked. – mbalparda Dec 15 '14 at 12:19
1

If your order already placed from admin - admin might have selected a customer or created using direct customer details.

If the order was placed from frontend then the order object will be having customer details.

By an case you will able to retrieve customer details of an order using

 $_order->getCustomer() 

From this you will able to retrieve all details of that order's customer(If they were logged in)

  • Are you sure the customer object will be only filled if the customer is logged in? – mbalparda Dec 15 '14 at 12:35
1

This question seems to be answered here: get current customer from admin section

A summary:

Mage::getSingleton('adminhtml/session_quote')->getCustomer();
-1

you can get the customer in admin

to get a full name use this -> addNameToSelect()

$customerList = Mage::getModel('customer/customer')->getCollection()
                                        ->addNameToSelect(); 
foreach ($customerList as $customer) {
            $customreArray[] = array(
                'value' => $customer->getId(),
                'label' => $customer->getName()
            );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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