I'm gonna add the column in my order -> shipment grid!
I want to bring the "title" on 'sales_flat_shipment_track' table. And it has also "parent_id" column, means entity_id on sales_flat_shipment!
sales_flat_shipment_track
sales_flat_shipment
So i need to implement this requirment to Mage_Adminhtml_Block_Sales_Shipment_Grid
What code do i have to insert to protected function _prepareCollection() & protected function _prepareColumns() ?
I tried :
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join('sales_flat_shipment_track', 'main_table.entity_id = sales_flat_shipment_track.parent_id', array('title'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
$shippingmethods = array();
foreach($methods as $_ccode => $_carrier) {
if($_methods = $_carrier->getAllowedMethods()) {
if(!$_title = Mage::getStoreConfig("carriers/$_ccode/title"))
$_title = $_ccode;
foreach($_methods as $_mcode => $_method) {
$_code = $_ccode . '_' . $_mcode;
$shippingmethods[$_code]= $_title;
}
}
}
$this->addColumn('title', array(
'header'=> Mage::helper('sales')->__('Shipping Method'),
'width' => '80px',
'type' => 'options',
'index' => 'title',
'options' => $shippingmethods,
));
}
Please let me know it
Thank you so much!