$bs = new CIBlockSection;
foreach ($tree as $key=>$value){
$add = $bs->Add(Array('NAME'=>$key, 'IBLOCK_ID'=>14,'CODE'=>$key), false,false);
if (!$add) echo $bs->LAST_ERROR;
foreach ($value as $key1=>$value1){
$add1 = $bs->Add(Array('NAME'=>$key1, 'IBLOCK_ID'=>14,'IBLOCK_SECTION_ID'=>$add,'CODE'=>$key1), false,false);
if (!$add1) echo $bs->LAST_ERROR;
foreach ($value1 as $key2=>$value2 ){
$add2 = $bs->Add(Array('NAME'=>$key2, 'IBLOCK_ID'=>14,'IBLOCK_SECTION_ID'=>$add1,'CODE'=>$key2), false,false);
if (!$add2) echo $bs->LAST_ERROR;
foreach ($value2["products"] as $key3=>$value3){
preg_match('#(<table cellpadding="4" cellspacing="0" border="0" class="text" width="100%")[\s\S]*?</table>#im',$content,$description);
$PROP = array ("model"=>$key3,"features"=>array("VAL UE"=>array("TEXT"=>$description[0],"TYPE"=>"html")),"vendor"=>$vendor[1],"goodcode"=>$code[1],"images"=>$arFils);
$arLoadProductArray = Array(
"CODE" => $key3,
"IBLOCK_SECTION_ID" => $add2,
"IBLOCK_ID" => 14,
"PROPERTY_VALUES"=> $PROP,
"NAME" => $key3,
"ACTIVE" => "Y",
"DETAIL_PICTURE"=>CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/upload/imgs/".$name_img),
"PREVIEW_PICTURE"=>CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/upload/imgs/".$name_img)
);
$el = new CIBlockElement;
if($PRODUCT_ID = $el->Add($arLoadProductArray)):
echo "New ID: ".$PRODUCT_ID;
else:
echo "Error: ".iconv("windows-1251","UTF-8",$el->LAST_ERROR);
exit();
endif;
}
}
}
} |