Jump to content
SomewhatNewby

Export to CSV (Excel)

Recommended Posts

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 by SomewhatNewby

Share this post


Link to post
Share on other sites

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.attachicon.gifproduct_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

Share this post


Link to post
Share on other sites

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();

Share this post


Link to post
Share on other sites

Hello gizmola,

 

Thank you for useful information. Have tried everything I know, but export button is still generating empty document. Without any actual data.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.