I added a custom attribute in to my default product type like so

Attribute Code: mfgpartnumber
Attribute Label: Manufacturer Part Number

This attribute is used to add products in Magento backend and I want to include this attribute in new order emails. I have researched so far and here is what I finally added

<?php $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('mfgpartnumber')); ?>
<?php echo $product->getAttributeText('mfgpartnumber'); ?> 

To /home/txsystems/store/app/design/frontend/base/default/template/email/order/items/order

That did not work, please can someone point me in the right direction on how to add custom attribute to Magento new order emails.


3 Answers 3


I prefer not to use loadByAttribute as it returns a resource collection call which uses "select *" by default. Try this instead:

$product = Mage::getModel('catalog/product')->load($_item->getProductId());

To add custom fields to Order Email, open the order email template located at



add the below code where you want

{{depend order.hasCustomFields()}}

<table cellspacing="0" cellpadding="0" border="0" width="650">



<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Custom Fields:</th>





<td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">

{{var order.getFieldHtml()}}








So as per the above code, you need two functions hasCustomFields() and getFieldHtml() in our Order class. So next you will override the Mage_Sales_Model_Order model. Open your config.xml file and inside section put in this code






and next create our new model class Excellence_Custom_Model_Sales_Order


class Excellence_Custom_Model_Sales_Order extends Mage_Sales_Model_Order{

public function hasCustomFields(){

$var = $this->getSsn();

if($var && !empty($var)){

return true;


return false;



public function getFieldHtml(){

$var = $this->getSsn();

$html = '<b>SSN:</b>'.$var.'<br/>';

return $html;

A better way is not to load the product by the item ID, but simply getting the product via the item:

$customAttribute = $_item->getProduct()->getCustomAttribute();


$customAttributeText = $_item->getProduct()->getAttributeText('custom_attribute');

And using that

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.