The template file for the "name" column in the sales backend is app/design/adminhtml/default/sales/items/column/name.phtml
Working with that file, you will be able to what you are after.
To avoid core changes, i'd suggest creating a module with a layout update
<adminhtml_sales_order_view>
<reference name="order_items">
<action method="addColumnRender">
<column>name</column>
<block>adminhtml/sales_items_column_name</block>
<template>module_name/sales/items/column/name.phtml</template>
</action>
<action method="addColumnRender">
<column>name</column>
<block>adminhtml/sales_items_column_name_grouped</block>
<template>module_name/sales/items/column/name.phtml</template>
<type>grouped</type>
</action>
</reference>
</adminhtml_sales_order_view>
You can also attach this override to other adminhtml_sales layouts, using the same reference/action methods above...
<adminhtml_sales_order_invoice_new />
<adminhtml_sales_order_invoice_updateqty />
<adminhtml_sales_order_invoice_view />
(use invoice_items reference for this layout)
<adminhtml_sales_order_shipment_new />
<adminhtml_sales_order_shipment_view />
(use shipment_items reference for this layout)
<adminhtml_sales_order_creditmemo_new />
<adminhtml_sales_order_creditmemo_updateqty />
<adminhtml_sales_order_creditmemo_view />
(use creditmemo_items reference for this layout)
Hope that helps
Vinoth,You can do this by event and observer. According to magento system,there are two event fire on every collection load.
One is collection load before and other is collection load after
Functionality,you can check at on class Mage_Core_Model_Resource_Db_Collection_Abstract
Event on collection load before:
protected function _beforeLoad()
{
parent::_beforeLoad();
Mage::dispatchEvent('core_collection_abstract_load_before', array('collection' => $this));
if ($this->_eventPrefix && $this->_eventObject) {
Mage::dispatchEvent($this->_eventPrefix.'_load_before', array(
$this->_eventObject => $this
));
}
return $this;
}
Event on collection load after:
protected function _afterLoad()
{
parent::_afterLoad();
foreach ($this->_items as $item) {
$item->setOrigData();
if ($this->_resetItemsDataChanged) {
$item->setDataChanges(false);
}
}
Mage::dispatchEvent('core_collection_abstract_load_after', array('collection' => $this));
if ($this->_eventPrefix && $this->_eventObject) {
Mage::dispatchEvent($this->_eventPrefix.'_load_after', array(
$this->_eventObject => $this
));
}
return $this;
}
Now if we add the custom table on basic of two event then it can fulfill yours requirement
Basically on the sales order collection load event we can add your custom table.Just Order grid load from sales/order_grid_collection
.This collection
collection these events are sales_order_grid_collection_load_before
and sales_order_grid_collection_load_after
. If we add custom table using joinLeft then it would be working good.
Example:
<adminhtml>
<events>
<sales_order_grid_collection_load_before>
<observers>
<amit_sales_order_grid_collection_load_before>
<class>Yourmodulem modelPrefix/observer</class>
<method>addmycustomtable</method>
</amit_sales_order_grid_collection_load_before>
</observers>
</sales_order_grid_collection_load_before>
</events>
</adminhtml>
Observer code:
<?php class MyNameSpace_Mymodule_Model_Observer
public function addmycustomtable(Varien_Event_Observer $observer)
{
$collection = $observer->getOrderGridCollection();
$select = $collection->getSelect();
$select->joinLeft(array('v' => 'additional_order_info'),
'main_table.entity_id = v.order_id',
array('*'));
}
}
Best Answer
Dinesh , Magento do not save
product publisher attribute and etc product attribute in sales_flat_order_item
so you can not getpublisher attribute
value from order itemSo need load Magento product Obeject (
Mage::getModel('catalog/product'))
by order item product($item->getProductId())
then you can thisattribute value if product is exit in magento