I'd like to programmatically save a views_data_export to a file and save it on the server for whoever wants to download it. The code should be triggered with cron nightly (I am using elysia_cron). I have managed to do that when the data export view "Batch export" is set to "No" but I want it to work also when it is set to "Yes".

I have delved into an issue on drupal org:
I am opening a new issue because the closest one that I have found is an old issue that isn't active - #1875456: How to programmatically save a views data export file to a repository/a node field/etc.
Also, my issue concerns Drupal 7, not 8.

There is a snippet that is related to the problem I encountered but it doesn't help me because I want to trigger the code by cron, not hook.

This is my code that works when no batching:

$view = views_get_view($view_name);
$display = $view->preview('views_data_export_csv');
file_unmanaged_save_data($display , PATH, FILE_EXISTS_REPLACE);

I might, I think, trigger the path of the (/views_data_export_csv) somehow, although tricky. But I prefer that the code wouldn't run when a user manually exports data, but instead by cron only.

Any ideas?

Thanks!

Comments

Amir Simantov created an issue. See original summary.

steven jones’s picture

Status: Active » Closed (won't fix)

Sorry for the lack of attention to your issue, please accept my apologies.

Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.

As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.

If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.

Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)