TransWikia.com

magento 1.9, export data from grid to csv file

Magento Asked by Denys Maksiura on November 29, 2020

I am trying to export data to from my module to CSV file

in my grid.php file i have this code in _prepareColumns()

$this->addExportType('*/*/groupDataExportToCsv',
            Mage::helper('purchasewizard')->__('CSV'));

        return parent::_prepareColumns();

in controller groupDataExportToCsvAction()

public function groupDataExportToCsvAction()
    {

        $fileName   = 'pw_groupdata.csv';
        $content    = $this->getLayout()->createBlock('purchasewizard/adminhtml_groupdata_grid')
            ->getCsvFile();
        $this->_prepareDownloadResponse($fileName, $content);

but in my CSV i have this

Id,Favorite,"Brand Template",Model,"Spec 1","Spec 2","Spec 3","Spec 4","Priority Index",Price,Stock,Sold,"On The Way","Last Price Update","Last Sold",Comment,Externals,"Item Type"
"<a href=""http://localhost:8888/index.php/purchasewizard/adminhtml_purchasewizard/assoc/id/24287/"" title=""Click to check associate product list"" target=""_blank"">24287</a>",No,Fujitsu,"MODEL1 QEWJJWQEK 312","MODEL1 QEWJJWQEK 312","MODEL1 QEWJJWQEK 312","MODEL1 QEWJJWQEK 312","MODEL1 QEWJJWQEK 312",0,,0,0,"
        <style>
            .actual_value, .changes_value{
                position: relative;
            }
            .actual_value .edit_pen{
                display: none;
            }
            .actual_value:hover .edit_pen{
                display: block;
            }
            .micro_btn{
                position:absolute; 
                top:2px; 
                right:2px; 
                font-size: 14px;
                color: blue;
                background: #fff;
                padding: 0 2px;
                border: 1px solid #cdcdcd;
                border-radius: 3px;
            }
            .changes_value {
                position: absolute;
                background: #5f9ea0;
                padding: 2px;
            }
            .changes_value .save_btn {
                color: limegreen;
                right: 24px;
            }
            .changes_value .cancel_btn {
                color: red;
            }
            .changes_value .micro_btn {
                padding: 0 3px;
            }
            .edit_field{
                width: 100px;
                margin-right: 45px;
            }
        </style>
        <div class=""actual_value"" style=""display: block;"">
            <span class=""table_value"">0</span>
            <span class=""micro_btn edit_pen"" >✎</span>
        </div><div class=""changes_value"" style=""display: none;"">
        <input class=""edit_field"" type=""text"" name=""on_the_way"" value=""0"">
        <span class=""micro_btn save_btn"">✔</span>
        <span class=""micro_btn cancel_btn"">✖</span>
        </div>",,,,No,"Hard Drives"
"<a href=""http://localhost:8888/index.php/purchasewizard/adminhtml_purchasewizard/assoc/id/24286/"" title=""Click to check associate product list"" target=""_blank"">24286</a>",No,Fujitsu,tested1,tested2,tested3,tested4,tested5,0,,0,0,"

how correctly export data to CSV file?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP