0

I am using Magento CE-1.9.2.x in my website.

Now I want Catalog >> Manage Products >> Actions select box to include the Export Products to XLS option, with only a custom controller and custom action in background to be able to export products to xls format.

I have seen content-type of application/octet-stream is allowed in _prepareDownloadResponse() function, how this can help me and also what should be column-separator for xls format ?

I want this with default Magento functions without the use of any third party libraries.

I have searched a lot on Google but couldn't find a reliable code block or post for this.

Hope anyone here can help me out.

2
  • The admin controllers you extend have the functions to generate excel files, you just need to call them. See core controllers for examples
    – scrowler
    Commented Dec 24, 2015 at 5:52
  • I saw the core-controllers, but haven't been able to figure out the format and separator things, can you provide an example for xls generation ?
    – Vicky Dev
    Commented Dec 24, 2015 at 5:54

2 Answers 2

3

.csv use "," seperated.

while .xls format uses tab seperated.

so remove "," and replace with Tab or "\t".

I hope this will help you.

1

The file generation isn't in controller the grid block is who performs such actions, so you should...

  1. Add a massiveAction in the main form block (add the action option)
  2. Add a controller action to route process/validate params (products selection) and instantiate right grid block
  3. Create a grid block to filter, prepare columns and load the collection and then returns to controller to be exported.

You can check the reports/sales/orders/ structure to figure out how to do these steps.

I don't know how xls format works, but i'm pretty sure that you could find a xls library in Zend Framework. Remember that any CSV could be perfectly opened in excel and you can natively export products in that format.

Anyway I have to say.. I don't thing that this would be a good idea due to complexity of catalog product entities. I strongly recommend to use another tool like import/export or data-flow profile to do that. If you have a couple of different attributes sets and export all products you could exceed the limit of joins that mysql can handle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.