cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 - The export error after customizing grid on shipment page

Magento 1.9 - The export error after customizing grid on shipment page

I got a issue about export our shipment information. Before i start with this issue, i add the "shipping method"column, is called customizing column, on shipment grid!

Like this,

 

app/code/core/Mage/Adminhtml/Block/Sales/Shipment/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'));*/
     $collection->getSelect()->join('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('shipping_method'));


    $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('shipping_method', array(
        'header'=> Mage::helper('sales')->__('Shipping Method'),
        'width' => '80px',
        'type'  => 'options',
        'index' => 'shipping_method',
        'options' => $shippingmethods,
        ));

    $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
    $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));

    return parent::_prepareColumns();
}

I can see the column i created but after export On the sales -> shipment on back-end page, i faced this issue!

 

Capture2.JPG

 

I guess it is resulted from that i deal with nothing with database. So The back-end page didn't bring the shipping method value from the table.

Do i need to join the tables directly?

The table which has the shipment grid informaion is "sales_flat_shipment_grid" And there is shipping description(shipping method) on "sales_flat_order"

 

 

Then, How can i export these grid info ? Thank you

1 REPLY 1

Re: Magento 1.9 - The export error after customizing grid on shipment page

Instead of trying to do this manually, just use the BL_Customgrid extension.

 

https://github.com/mage-eag/mage-enhanced-admin-grids/tree/0.8.9

 

(There is a 0.9.0 version too, but I haven't used it. Although it says it is un-maintained, we have used 0.8.9 in about 75 stores, and have seen no major issues with it.)

 

If you must do it manually, we need to see the actual error message to provide any sort of useful input.

 

Best Practice tip: You should avoid modifying core files like you are doing. It's best to use an observer instead.