SomewhatNewby Posted August 3, 2016 Share Posted August 3, 2016 (edited) Hello guys, I am trying to modify OpenCart plugin to be able to export certain data to Excel file format. What I managed to do is this. When clicked on Export button, .CSV file is generated, but it is empty. Actual data is missing. What am I doing wrong? Can somebody alter my code? It drives me freaking nuts. PHP file is attached. Thank you.product_warranties.php P.S. Am also willing to pay for this, I guess small code edit. Edited August 3, 2016 by SomewhatNewby Quote Link to comment https://forums.phpfreaks.com/topic/301744-export-to-csv-excel/ Share on other sites More sharing options...
gizmola Posted August 4, 2016 Share Posted August 4, 2016 Hello guys, I am trying to modify OpenCart plugin to be able to export certain data to Excel file format. What I managed to do is this. When clicked on Export button, .CSV file is generated, but it is empty. Actual data is missing. What am I doing wrong? Can somebody alter my code? It drives me freaking nuts. PHP file is attached. Thank you.product_warranties.php P.S. Am also willing to pay for this, I guess small code edit. I just want to point out that .csv is not an excel specific format. It is something that traditionally excel has been able to import, but there are also many databases that can import csv files in most cases. There are libraries which can be used to create excel format files more directly. For example there is this project: https://github.com/PHPOffice/PHPExcel Quote Link to comment https://forums.phpfreaks.com/topic/301744-export-to-csv-excel/#findComment-1535557 Share on other sites More sharing options...
gizmola Posted August 4, 2016 Share Posted August 4, 2016 As for the code, it seems clear that there is something missing in the export method of the class. At line 148 of your script: foreach ($warranties as $warranty_id) { This is the loop that should be outputting data, but $warranties is undeclared or initialized, so the loop would never be entered into. I don't know a whole lot about opencart plugins, nor do I understand the model system, or the specifics of your model, but if I were to make an educated guess: Just prior to line 148 something like this would be expected: $warranties = $this->model_catalog_product_warranties->getProductWarranties(); Quote Link to comment https://forums.phpfreaks.com/topic/301744-export-to-csv-excel/#findComment-1535559 Share on other sites More sharing options...
SomewhatNewby Posted August 4, 2016 Author Share Posted August 4, 2016 Hello gizmola, Thank you for useful information. Have tried everything I know, but export button is still generating empty document. Without any actual data. Quote Link to comment https://forums.phpfreaks.com/topic/301744-export-to-csv-excel/#findComment-1535593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.