Magento 1.9 – Add Custom Attribute in Admin Sales Order

adminhtmlmagento-1.9orders

i want to custom attribute(publisher) below product name in Admin > sales > order > view
i am talking about this example admin url
yourdomain.com/index.php/admin/sales_order/view/order_id/194/key/8708c389d84db52a806a3411d367368b/

i am making change in app\design\adminhtml\default\default\template\sales\items\column\name.phtml
my question is first how to override this core file & how to get custom attribute publisher name below product name
i try this code to get publisher name but not working

<div><strong><?php echo $this->helper('sales')->__('Publisher') ?>:</strong> <?php echo implode('<br />', Mage::helper('catalog')->splitpublisher($this->escapeHtml($this->getpublisher()))); ?></div>

enter image description here

Best Answer

Dinesh , Magento do not save product publisher attribute and etc product attribute in sales_flat_order_item so you can not get publisher attribute value from order item

So need load Magento product Obeject (Mage::getModel('catalog/product')) by order item product($item->getProductId()) then you can this attribute value if product is exit in magento

$product=Mage::getModel('catalog/product')->load($item->getProductId());
  if($product->getId()){
  /* product is exiting in magento
  $publisher=$product->getPublisher();
  }else{
    /* product has been deleted from  magento  so you can not get product data */

  $publisher='None';
  }
Related Topic