Magento – How to add CSV Import/Export Functionality

csvexportimportmagento-1magento-1.7

I have created custom gallery extension but I need to implement an import and export or gallery data in the CSV Format.

I did too much research but couldn't find any useful link to find solution so please let me know if anybody had idea for this.

Best Answer

For a CSV exports you can generate a grid with your data and use the getCsv() function. Sounds overhead, but that's exactly what the export of the Tablerates shipping cost table in the backend does.

See: Mage_Adminhtml_System_ConfigController::exportTableratesAction and Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid.

For the import you could also have a look at this module (Mage_Shipping_Model_Resource_Carrier_Tablerate::uploadAndImport) or on the import module for product data (Mage_ImportExport), but this is much more complicated.

Related Topic