$rsSections = $sect_obj->GetList(array('ID'=>'ASC'), array('IBLOCK_ID'=>MAIN_CATALOG_IBLOCK_ID));
while($arSect = $rsSections->Fetch()) $arSectCodeID[$arSect['CODE']] = $arSect['ID'];
foreach($arVals as $arItem){
$arFields = array(
'IBLOCK_ID' => MAIN_CATALOG_IBLOCK_ID,
'IBLOCK_SECTION_ID' => $arSectCodeID[$arItem['PARENT']],
'NAME' => $arItem['NAME'],
'CODE' => $arItem['CODE'],
'PROPERTY_VALUES' => array(
'ART' =>$arItem['ART'],
'STORAGE' =>$arItem['STORAGE']
),
);
$new_item_id = $elem_obj->Add($arFields);
if(!$new_item_id) echo('<p>'.$elem_obj->LAST_ERROR.' - '.print_r($arFields,1).'</p>');
} |