Magento – Add Custom Attribute to New Order Email Magento 1.7

magento-1.7

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.

Best Answer

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());
Related Topic