It's the SilverStripe bulk loader, but ever so slightly better
It's the SilverStripe bulk loader, but ever so slightly better!
This module expands the default SS version and adds error logging per import row and attempts to solve issues where Excel sometimes
adds blank columns to the end of a CSV (which then fails to import)
Instalation via composer:
# composer require i-lateral/silverstripe-slightly-better-bulkloader
By default this module should automatically replace BulkLoader_Result
with a custom version
that track errors.
However to make the most of this, you need to also implement your own version of CSVBulkLoader
for example:
Adding the Custom CSV uploader via ModelAdmin
namespace App\Admin;
use SilverStripe\Admin\ModelAdmin;
use ilateral\SilverStripe\SlightlyBetterBulkLoader\CsvBulkLoader;
class MyModelAdmin extends ModelAdmin
{
private static $managed_models = [
MyDataObject::class
];
private static $model_importers = [
MyDataObject::class => CsvBulkLoader::class
];
}
An example of adding a custom CSV import after a form has been submitted.
use SilverStripe\Forms\Form;
use ilateral\SilverStripe\SlightlyBetterBulkLoader\CsvBulkLoader;
class MyImportForm extends Form
{
public function import($data, $form)
{
$loader = CsvBulkLoader::create();
$results = $loader->load($_FILES['_CsvFile']['tmp_name']);
$form->sessionMessage(
$results->getMessagesString("</br>"),
$results->getMessageType(),
ValidationResult::CAST_HTML
);
return $this->redirectBack();
}
}
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem