Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Remove columns from grid before CSV export
 
DavidMagentoTypo3
Jr. Member
 
Total Posts:  3
Joined:  2010-12-09
 

Magento 1.4.1.1

I would like to know if there is a solution if i want to remove a specific column from this:

/**
     * Export products grid
     *
     */
    public function exportCsvAction() {
        $fileName 
'products.csv';
        
$content $this->getLayout()->createBlock('AdvancedStock/Product_Grid')
                        ->
getCsv();

       

        
$this->_prepareDownloadResponse($fileName$content);
    
}

I want to unset specific column from this:

$this->getLayout()->createBlock('AdvancedStock/Product_Grid')

My client don’t need all the grid infos from the Export CSV.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Andre N
Sr. Member
 
Avatar
Total Posts:  186
Joined:  2009-12-09
CA
 

In your Grid.php file, in the function _prepareColumns(), wrap the columns that you do not want exported to CSV/XML in an if statement like this:

if ( ! $this->_isExport {
    $this
->addColumn('something', array(
            
'header'        => Mage::helper('sales')->__('Something'),
            
'index'         => 'something',
        ));
}
That way it will not be added to your exports to begin with and there will be no need to remove it
 
Magento Community Magento Community
Magento Community
Magento Community
 
xiaoyuandlg
Jr. Member
 
Total Posts:  3
Joined:  2014-01-12
 

What a coincidence that I am almost able to answer your question if I know more about the export grid to CSV. I just read something about the removing rows from grid in C#, don’t know if they have some similar technique in common.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top