cancel
Showing results for 
Search instead for 
Did you mean: 

Generate .csv file with order data, and save to upload dir

Generate .csv file with order data, and save to upload dir

Hi everyone!

 

I started working with frontend in magento2 about 1.5 months ago, and now I was asked to add a feature to the website, which requires a bit of backend knowledge (module, events, file generation).

 

Here is my task: every time an order is placed, I have to save that orders data (in custom format) into an xml file, and store that file in /upload/orders folder

 

I planned on making a module with observer for an even that fires when order is placed, and then generating the file in that observer. But, how do I generate that file, and how to then store it? Any ideas? At least some sort of tips would be more than welcome.

 

I am in a bit over my head here, but Its how I also started with frontend, and its how i learned pretty quickly, so I really wanna finish this task.

 

Thank you so much!

-B

1 REPLY

Re: Generate .csv file with order data, and save to upload dir

Hi @blaz_p,

 

I guess you'll find several ways to get the data.

Maybe you can start with an observer to capture the order data everytime is placed (or maybe you can capture only the ID and the try to read the whole Order data).

Using queues is another option (it will depend on which version and edition of Magento are you using).

I'm not sure, I guess you could start with the first idea and then start to improve performance.

 

(my 2 cents)

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"