顯示包含「massaction」標籤的文章。顯示所有文章
顯示包含「massaction」標籤的文章。顯示所有文章

2014/04/04

Pop out file download message in admin grid massaction

Inside the massaction controller, e.g. Mage_Adminhtml_Sales_OrderController By default, those print invoice options do this:
 
return $this->_prepareDownloadResponse( //edit by leo - change file name $filename.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf' );
But you can not just output pdf/file, csv is also ok
 
$data = 'your csv data'; $this->_prepareDownloadResponse('file.csv', $data, 'text/csv');
In my situation, I generate shipping label in HTML format. As massaction action does not allow opening the action in the blank page, so i assign those html content into a html file.
 
$html = $block->toHtml(); $filename = 'form_'. Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.html'; return $this->_prepareDownloadResponse($filename, $html, 'text/html');