-
Notifications
You must be signed in to change notification settings - Fork 0
Lindab How to import data from CSV file
- The CSV file must contain columns from "mappings" and vice versa, and as a delimiter we use ";".
- On the server the import time lasts, we have to wait until all the data is imported.
- Locally only part of the CSV file is imported.
Files for import in Lindab are:
- For products -> https://drive.google.com/drive/folders/16MRUATC4SOKhLvY8aCOgNIGgtzNlfUg_
- For productsgroup -> https://drive.google.com/drive/folders/16MRUATC4SOKhLvY8aCOgNIGgtzNlfUg_
- For planners -> https://drive.google.com/drive/folders/16MRUATC4SOKhLvY8aCOgNIGgtzNlfUg_
- For partnercompanies -> https://drive.google.com/drive/folders/16MRUATC4SOKhLvY8aCOgNIGgtzNlfUg_
In this example we import / update the product groups
- The function for import in the object:
public function importProductGroupData($data, $mappings = [])
{
\Application\Controller\Log::getInstance()->AddRow('mappings importCsv');
// import into parent with mapped parent via external relations
$this->importParentCsv(0, "Productgroup", $data, $mappings);
}
-
The function for import in Workspace:
public function importProductGroupData($data){$log = \Application\Controller\Log::getInstance();$log->AddRow('ImportProductGroup >-on parent --> ' . json_encode($data));$dataNew = json_decode($data, true);$log->AddRow('ImportProductGroup >-on parent --> ' . json_encode($dataNew));\Application\Controller\Log::getInstance()->AddRow('mappings importCsv');$mappings = array("category" => "category","gama" => "gama");// import into parent with mapped parent via external relations$this->importParentCsv($this->getIdAsString(), "Productgroup", $dataNew[0], $mappings);return "Product group DATA IMPORTED";}
3.The function in workspace(This is an exmple):
$data = array(
"name" => "adminimport_csv_Productgroup",
"actionExecution" => "inputform",
"actionResponse" => 'refreshAll();',
"viewId" => "viewId",
"link" => "Importa din fisier CSV/Excel",
"type" => "list",
"parentType" => "Workspace",
"objectType" => "Productgroup",
"method" => "importDialogProductgroup",
"serviceName" => "",
"serviceMethod" => "",
"template" => "",
"scope" => "user"
);
`$mongoObjectFactory->createAndAdd($typeComponent, (string)$returnAdminComponentGridProductgroup, $typeContextMenu, $data);`
`$workspaceD->createField($viewId, "importDialogProductgroup", \Application\Document\Field::TYPE_FILE, "", "fileName", "Fisier CSV/EXCEL", true, "", "");`
`$workspaceD->createField($viewId, "importDialogProductgroup", \Application\Document\Field::TYPE_BUTTON, "", "save", "Importă/actualizează productgroup", true, "method", "", "importProductGroupData(@fileName@);", "", "showMessage(\"@name@\");");`
tes