3

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()
{
parent::_prepareColumns();

$this->removeColumn('created_at');

$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('created_at', array(
    'header'    => Mage::helper('sales')->__('Date Shipped'),
    'index'     => 'created_at',
    'type'      => 'datetime',
    'filter_index' => 'main_table.created_at'
));

$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 $this; } I can see the column i created but after export On the sales -> shipment on back-end page, i faced this issue!

enter image description here And log said

ERR (3): Warning: SimpleXMLElement::__construct(): </html> in /home/kbethos/public_html/wh-clone/app/code/core/Mage/AdminN‌​otification/Model/Fe‌​ed.php on line 173 

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

2

This error means that MySQL is not able to filter the results because column created_at is in both used tables and it doesn't know which one to use. You have to set something like that on created_at column for this grid :

protected function _prepareColumns()
{
parent::_prepareColumns();

$this->removeColumn('created_at');

$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('created_at', array(
        'header'    => Mage::helper('sales')->__('Date Shipped'),
        'index'     => 'created_at',
        'type'      => 'datetime',
        'filter_index' => 'main_table.created_at'
    ));

    $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 $this;
}

This should help.

  • Where do i have to this code? Could you let me know where i have to add it after specific line? – 3CE Mar 15 '17 at 14:47
  • I add it to $this->addColumn('shipping_method', ~~ but it doesn't work – 3CE Mar 15 '17 at 14:50
  • btw, When i click export, the website is stopped and finally, export is not proceeded. What should i do? – 3CE Mar 15 '17 at 14:58
  • it works! Thank you! – 3CE Mar 15 '17 at 15:16

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.