D
D
doorway-team2018-03-01 11:48:13
1C-Bitrix
doorway-team, 2018-03-01 11:48:13

How to automate the import of CSV users to 1C-Bitrix?

There is a regular functionality (/bitrix/admin/user_import.php) for importing users from CSV (created from a template).
Actions are:

  1. data file selection
  2. linking imports to user groups
  3. and other settings

But it's all manual. Question - how to make it automatically valid once a day?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-01
@megafax

Set a task in cron (or agent), sample code (taken from the same file that is responsible for import)

$csvImport = new CSVUserImport($csvFilePath, $arDelimeters[$delimeter]);
$csvImport->SetUserGroups($userGroups);
$csvImport->IgnoreDuplicate($ignoreDuplicate == "Y");
$csvImport->SetCallback("_OnUserAdd");
$csvImport->SetImageFilePath($pathToImages);
$csvImport->AttachUsersToIBlock($attachIBlockID);

if (!$csvImport->IsErrorOccured()) {
  $csvFile =& $csvImport->GetCsvObject();
  while ($csvImport->ImportUser()) {
    /* ... тут можно делать список ошибок для дальнейшего вывода ... */
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question