i'd like to add Carrier (shipping method_ column on magento admin pate under magento> sales> shipments
i put this code in Grid.php
protected function _prepareCollection()
{ $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect()->join('sales_flat_order', 'main_table.entity_id =sales_flat_order.entity_id',array('shipping_method')); $this->setCollection($collection);z return parent::_prepareCollection(); }
$this->addColumn('shipping_method', array( 'header'=> Mage::helper('sales')->__('Shipping Method'), 'width' => '80px', 'type' => 'options', 'index' => 'shipping_method', 'options' => $shippingmethods, ));
but What i want to be shown is carrier title....like UPS, USPS, DHL that code show me bit different result tThx n
1 Answer 1
$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('shipping_method', array(
'header'=> Mage::helper('sales')->__('Shipping Method'),
'width' => '80px',
'type' => 'options',
'index' => 'shipping_method',
'options' => $shippingmethods,
));
try above code. Hope it helps to get Shipping Title. Thanks
-
i did but it didn't workDiny Na– Diny Na2017年03月13日 15:22:14 +00:00Commented Mar 13, 2017 at 15:22