Using Import/Export feature from a theme / frontend?

Anyone previously ported the existing Import/Export feature from a theme / frontend (therefore from a component)?

Hi @chris

This could help.

Importing with PHP

Use the importFile method process an import manually from a local file stored on the disk.

$importModel = new MyImportClass;

$importModel->file_format = 'json';


If the file is coming from an uploaded file use the Input facade to access the local path.


Exporting with PHP

Use the exportDownload method to process an export manually and return a download response.

$exportColumns = ['id', 'title'];

$exportModel = new MyExportClass;

$exportModel->file_format = 'json';

return $exportModel->exportDownload('myexportfile.json', ['columns' => $exportColumns]);