2

I'm trying to add custom fields in the order information. I found this on app/design/adminhtml/default/default/template/sales/order/view/info.phtml

But I did not intend to change it directly to the core

enter image description here

What is the correct way to do this? Thanks in advance.

1 Answer 1

1

If you look into Mage_Adminhtml_Block_Sales_Order_View_Info you will see the function getCustomerAccountData. This function loads all the attributes_codes attached to the customer entity, loops through them and checks to see if they are attached to the order.

$orderKey   = sprintf('customer_%s', $attribute->getAttributeCode());
$orderValue = $this->getOrder()->getData($orderKey);

So one way of showing these attributes is simply to add them to the order, with the prefix customer_ and then they will show up on this page.

One reason for saving this information against the order is to keep a record of what state the customer was in when ordering. For some information this is fairly important, but not knowing what your fields are I am not sure if this is a problem for you or not.

A quicker, but possibly not so nice way would be to change this function and load the information directly from the customer. Obviously it is your choice and it is really a matter of what the data is as to if you want it "live" or saved as the state of order, but if you think about the address or customer email address you would want these to be saved against the order. Personally I would add these attributes to the order.

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.