Does somebody know why field customer_address_id is null on sales_flat_order_address table? As regards to order for customer who has an address.

In class: Mage_Sales_Model_Order_Address I found this:

protected function _beforeSave()


    if (!$this->getParentId() && $this->getOrder()) {

    // Init customer address id if customer address is assigned
    if ($this->getCustomerAddress()) {

    return $this;

1 Answer 1


The field customer_address_id is a reference to the customer_address table.
When placing an order as guest you have to fill in the address manually.
When you do that there is no customer address object to reference in the checkout so customer_address_id is null.
This also happens when you checkout as a customer, but fill in a new address and you DO NOT choose to save the address in your address book.

The field has a value only when you checkout as a logged in customer and select one of the addresses in your address book, or you add a new address and choose to save it in your address book.

  • Thank you for a quick answer. Cause of problem was a custom modification of opc.
    – Krzysztof
    Jul 9, 2014 at 9: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.