0

I would like to export placed orders (regardless of status) including products to a .CSV file. I want one row describing the order and one row for each product in the order.

I want the output to be something like this,

enter image description here

As you can see, it's kind of like a pick slip. The main point is that I want two sets of "headers" for each order and its' products.

Is this possible to output to a CSV file? I don't want a PDF. I'm fairly new to magento, so please bare with me. Anyone have a decent guide or similar?

No paid modules(!). Don't mind customising free modules though.

1 Answer 1

0

It doesn't have much to do with Magento, it's more the fact that you have to learn how to use fputcsv

What you'll have to do is have 2 sets of arrays containing strings (header and subheader). Then :

  • Loop through your order collection
  • Print your header using fputcsv and your header array to your file.
  • Print the order details (Id, dataX, dataY...) using fputcsv.
  • Print the subheader using fputcsv and your subheader array.
  • Loops through your order items
  • Print item data using fputcsv.

You're then done ;)

With all that said, it doesn't really answer the fact that you want to do it via the Order Grid... Order Grid is kinda tricky, but I'm sure you'll find answers in here to customize it.

If you can't be bothered, add a link to a custom script then spit out the content of the CSV to the user (by setting the right headers) ; or create a cron that will periodically execute your script to print out Orders in a CSV file.

2
  • Thank you for your time and answer. I get the concept, and I think I will be able to sort this out. Though, I'm quite sure that I will be back with more questions sooner or later. Cheers. I suppose the only reason why i want to do it from the sales order grid is because: 1. Other mass actions are placed there (And in other places of course, lame, but still, since I'm new to Magento, I thought it would be the easiest way. It's not absolutely required at all) 2. It seemed easy to use the existing date selector if you want to export only a couple of orders. Commented Oct 7, 2015 at 6:50
  • I understand that if you're now to Magento, if might seem difficult to do a custom script, but it might be worth it because 1. Magento exports take forever. 2. They are quite dodgy, in the way that you sometimes end up with tons of unecessary data. Trust me, you're better off writing your own import/export scripts for efficiency purposes. You can even execute them with a command line and pass arguments such as dates if you want, then use those arguments to filter your order collection. Commented Oct 7, 2015 at 7:38

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.