In the Invoice PDF I can get (logged in) customer account data with the following code:

$customer_email = $order->getCustomerEmail();
$customer = Mage::getModel("customer/customer"); 

If I try to use this code in the shipment PDF (Mage/Sales/Model/Order/Pdf/Shipment.pdf), the customer data remains empty.

Given the customer email in $order, how can I get the account data in the shipment PDF?

2 Answers 2


I think you can use $order->getCustomerId() instead of getCustomerEmail. Then you can just load the customer like this:

$customerId = $order->getCustomerId();
if ($customerId) { //the order was not placed as guest
else {
    //order was placed as guest.

Doing it like this, you won't need to set a website id to the customer model before loading it.


Since the PDF is created from the backend the current Website ID will be 0 (admin). Depending on in what method you are trying to use your code snippet you might want to do something like this:

function getPdf

$customer_email = $order->getCustomerEmail();
$customer = Mage::getModel("customer/customer"); 

I'm using the getStore() data from the shipment object. This way it gets the store the order was placed from.

  • On the third line I get the following error: Fatal error: Call to a member function getId() on a non-object. As @Marius solutions works, this is not relevant to me anymore, but still wanted to give feedback.
    – SPRBRN
    Commented May 7, 2014 at 15:20
  • @SPRBRN thank you for the feedback. Ill look into it later on to correct the answer Commented May 7, 2014 at 15:45
  • @SanderMangel. Fixed it. It was getWebsiteId() but should be getWebsite()
    – Marius
    Commented May 15, 2014 at 2:35

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.