I want to edit the template /app/design/adminhtml/default/default/template/sales/items/column/name.phtml
This so that I can add my own custom attribute to the sales order. Therefore I created a line, that does work perfect for orders with products that still exists.
But when the order contains products that has been removed, the sales order does not load and the page breaks.
How can I change my line, so that it checks if the attribute value exists (or if the product still exists)?
CODE;
<?php $product_dpn = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('dpn'));
$product_mpn = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('mpn')); ?>
<div><?php if ($product_dpn->getDpn()): echo $product_dpn->getDpn(); endif; ?></div>
<div><?php if ($product_mpn->getMpn()): echo $product_mpn->getMpn(); endif; ?></div>