2

How to get all shipping method label in Custom Grid admin module . I am using the below Code .Its returning all shipping method Lable But i need all those as a collection . So i can use it my Custom admin grid .Can Any One Help us out

$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
$shipMethods = array();
foreach ($methods as $shippigCode=>$shippingModel) 
{
    $shippingTitle = Mage::getStoreConfig('carriers/'.$shippigCode.'/title');
    $shipMethods[$shippigCode] = $shippingTitle;
}
return $shipMethods;
7

According to your example, the shipping title may or may not be derived from the database. Thus, the collection cannot be created directly. It should still be possible to create your collection afterwards – once you have all necessary data at hand:

$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();

$shipMethodCollection = new Varien_Data_Collection();
foreach ($methods as $shippingCode => $shippingModel)
{
    $shippingTitle = Mage::getStoreConfig('carriers/'.$shippingCode.'/title');
    $shipMethod = new Varien_Object(array(
        'code' => $shippingCode,
        'title' => $shippingTitle,
    ));
    $shipMethodCollection->addItem($shipMethod);
}
return $shipMethodCollection;
0

Check out Mage_Adminhtml_Model_System_Config_Source_Shipping_Allmethods

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.