Documentation

Add

Description and parameters

mixed
CCatalogImport::Add(
   array arFields
);

Method adds new import profile. Non-static method.

Note: You cannot avoid CheckFIelds when entering values to this method, with a single exception:
"=LAST_USE" => $DB->GetNowFunction()

Call parameters

Parameters Description
arFields Available fields:
  • CREATED_BY - user profile ID. In case the value of this field is not passed, takes value from parameter CUser if $USER and authentication are available. Otherwise, this field will have NULL;
  • MODIFIED_BY - user profile ID. In case the value of this field is not passed, takes value from parameter CUser if $USER and authentication are available. Otherwise, this field value will have NULL;
  • TIMESTAMP_X - time of the last profile update in site format. This field cannot be specified manually;
  • DATE_CREATE - date when profile in site format is created. This field value be specified manually;
  • FILE_NAME - profile file name with script to perform import;
  • NAME - import profile name;
  • IN_MENU - [Y|N] flag for showing profile in admin menu;
  • DEFAULT_PROFILE - [Y|N] attribute to use profile by default;
  • IN_AGENT - [Y|N] flag for available agent, performing profile import;
  • IN_CRON - [Y|N] flag for associating the profile to cron utility for automatic periodic upload (for Unix systems only);
  • SETUP_VARS - profile setup parameters as URL string;
  • NEED_EDIT - [Y|N] flag specifies incomplete profile setup (profile is not executed until its edited).

Returned value

Method returns code for inserted record or false otherwise.

Examples

Adding a pre-set CSV import profile that requires a setup:

$arFields = array(  
   "FILE_NAME" => "csv_new",   
   "NAME" => "My import", 
   "NEED_EDIT" => "Y", 
   "SETUP_VARS"    => false
);  
CCatalogImport::Add($arFields);

Adding a profile with specified time of last use (current time only). Displays it in the left menu:

$arFields = array(  
   "FILE_NAME" => "csv_new", 
   "NAME" => "My second import", 
   "=LAST_USE" => $DB->GetNowFunction,  
        "IN_MENU" => "Y",
   "SETUP_VARS" => "IBLOCK_ID=15&FILE_DATE=import.csv" //  set of parameters is quite relative
); 
CCatalogImport::Add($arFields);

Adding profile with user who created the profile:

$arFields = array(  
   "FILE_NAME" => "csv_new", 
   "NAME" => "My second import", 
   "=LAST_USE" => $DB->GetNowFunction,  
        "IN_MENU" => "Y",
   "SETUP_VARS" => "IBLOCK_ID=15&FILE_DATE=import.csv", //  set of parameters is quite relative 
   "CREATED_BY" => 15, // user with ID = 15 
   "MODIFIED_BY" => 15 // must match with CREATED_BY
); 
CCatalogImport::Add($arFields); 


© «Bitrix24», 2001-2024
Up