2

I have a client in a situation where they need to provide physical CSV files on-disk for various and sundry reasons. The CSV would need to be populated with data fetched from the DB.

Now, I can totally prepare a custom template that would result in a CSV-formatted response via HTTP, but how do I save that response to disk? (EDIT: Is there perhaps some way to use a caching method of some sort to write the output to disk?)

In case it helps clarify things, the situation is a client who uses a fulfillment center for hosting and managing their non-EE shop. They now want to move to Expresso Store for the shop, but still use the fulfillment center to manage things. The fulfillment center wants to continue working with their own system of order management, but they can set up their system to fetch via FTP nightly updates in the form of CSV files to update their system with the latest orders from the Expresso Store.

  • Sorry I added an answer but then quickly saw that I was misreading the requirements. Is FTP the only method the fulfillment center has to pull data? They can't make an HTTP request? – Derek Jones Mar 4 '15 at 14:20
  • Hey Derek, they can use other methods, but are really really reluctant to do so. They would rather even go through the headache of figuring out direct DB access before HTTP requests. No idea why TBH. Thankfully, looks like Rob's answer below should do the trick. – Sandwich Mar 4 '15 at 17:18
5

I'd recommend turning on "Enable HTTP Authentication?" for your template, so that you must use a username/password to access it, and then setting up a Cron job on your server to save to disk on a nightly basis:

00 00 * * * curl http://username:password@yoursite.com/your/template > /var/www/csv/`date +\%Y\%m\%d\%H\%M\%S`.csv
  • This is most likely the best implementation. You can also test this in your favorite command line tool before configuring it in your crontab on your server. – Jarrett Barnett Mar 4 '15 at 15:52
  • Whoa... that's exactly the sort of thing I was hoping to find out! Thanks Rob, that's awesome! – Sandwich Mar 4 '15 at 17:16
1

Not sure exactly what your needs are but would NSM Reports solve your problems?

  • Thanks, but after looking through the documentation, it doesn't look like NSM Reports provides any way to save reports to disk. – Sandwich Mar 4 '15 at 14:11
  • I use this one a lot for reports: exports to csv devot-ee.com/add-ons/ajw-export Simple to use – Jim Wyse Mar 4 '15 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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