Parsing

parents
Pipeline #148 failed with stages
<?require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php");
error_reporting(0);
ini_set('display_errors', 0);
setlocale(LC_ALL, 'ru_RU');
date_default_timezone_set('Europe/Moscow');
header('Content-type: text/html; charset=utf-8');
require('phpQuery/phpQuery.php');
require('PHPExcel/PHPExcel.php');
use Bitrix\Main\Loader;
Loader::includeModule('main');
$catalogUrl1 = 'https://hypower.ru/catalog/dlya_raytools_lazernaya_svarka/';
// запись в excel: $deleteTag - удалять ли теги в описании
function ParseToExcel($catalogUrl,$deleteTag = false){
$path_img = 'lazernaya_svarka_i_ochistka';
//$filename = 'hypower.xls';
$filename = 'hypower.xlsx';
$arrName = array();
if(file_exists($filename)){
$xls = PHPExcel_IOFactory::load($filename);
$worksheet = $xls->getActiveSheet();
$lastRow = $worksheet->getHighestRow();
$sheet = $xls->getActiveSheet();
$i = $lastRow;
/* echo '<pre>';
print_r($lastRow);
echo '</pre>'; */
}else{
$xls = new PHPExcel();
$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
$sheet->setTitle('Товары');
// Формат
$sheet->getPageSetup()->SetPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Ориентация
// ORIENTATION_PORTRAIT — книжная
// ORIENTATION_LANDSCAPE — альбомная
$sheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
// Поля
$sheet->getPageMargins()->setTop(1);
$sheet->getPageMargins()->setRight(0.75);
$sheet->getPageMargins()->setLeft(0.75);
$sheet->getPageMargins()->setBottom(1);
$sheet->setCellValue("A1", "номер позиции");
$sheet->setCellValue("B1", "номер папки с фото (совпадает с артикулом)");
$sheet->setCellValue("C1", "Артикул");
$sheet->setCellValue("D1", "Наименование");
$sheet->setCellValue("E1", "Описание");
$sheet->setCellValue("F1", "Характеристики");
$sheet->setCellValue("G1", "Картинка");
$i=1;
//print_r('no');
}
//exit;
//создаем документ
//берем основную страницу каталога и переходим в подкатегории
/* $doc_sec = phpQuery::newDocument(file_get_contents($catalogUrl));
$entry_sec = $doc_sec->find('.section_block .item a');
foreach ($entry_sec as $row_sec) {
$ent_sec = pq($row_sec);
$url_subsection = $ent_sec->attr('href'); */
//$doc_subsec = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_subsection));
$doc_subsec = phpQuery::newDocument(file_get_contents($catalogUrl));
$entry_subsec = $doc_subsec->find('.section_block .item div.name a');
foreach ($entry_subsec as $row_subsec) {
$ent_subsec = pq($row_subsec);
$url_subSubsection = $ent_subsec->attr('href');
//получаем страницу с товарами
$doc_subSubsec = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_subSubsection));
//если нет постраничного вывода или первая страница
$entry_subSubsec = $doc_subSubsec->find('.item_info--top_block a');
foreach ($entry_subSubsec as $row_subSubsec) {
//$sheet->setCellValue("A".$i, $i);
$url_item = trim(pq($row_subSubsec)->attr('href'));
$doc_detail = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_item));
//получаем название товра
$entry_title = $doc_detail->find('.top_info h1');
$title = trim(pq($entry_title)->text());
if(in_array($title, $arrName)){
continue;
}
$i = $i+1;
$arrName[$i] = $title;
/* echo '<pre>';
print_r($url_item);
echo '</pre>'; */
//получаем артикул товра
//$arTitle = explode(" ", $title);
//$article = $arTitle[0];
//получаем описание
$entry_text = $doc_detail->find('.tabs_section .row div.col-md-12');
$entry_text->find('h4')->remove();
//$entry_text->find('img')->remove();
//$entry_text->find('p[style="text-align: center;"]')->remove();
$entry_text->find('.low-price-mobile')->remove();
$descr = pq($entry_text)->html();
if($deleteTag){
//$descr = strip_tags($descr);
$descr = strip_tags($descr, '<br>');
$descr = str_replace('<br>','',$descr);
$descr = str_replace(' ','',$descr);
}else{
$descr = str_replace('/upload','https://hypower.ru/upload',$descr);
}
//запись описания в файл
/* $sheet->getColumnDimension("E")->setWidth(100);
$sheet->getStyle("E".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("E".$i, $descr); */
//получаем характеристики
$arProps = array();
$entry_prop = $doc_detail->find('.props_list tr');
$jPr = 0;
$strToFile = '';
foreach ($entry_prop as $row_prop) {
$ent_prop = pq($row_prop);
$entNameProp = $ent_prop->find('.char_name span[itemprop="name"]');
$arProps[$jPr]['name'] = trim(pq($entNameProp)->text());
$entValueProp = $ent_prop->find('.char_value span[itemprop="value"]');
$arProps[$jPr]['value'] = trim(pq($entValueProp)->text());
//получаем артикул товра
//$arTitle = explode(" ", $title);
if($arProps[$jPr]['name'] == 'Артикул Ref.'){
$article = $arProps[$jPr]['value'];
}
$strToFile .= $arProps[$jPr]['name'].' : '.$arProps[$jPr]['value']. ';';
$jPr++;
}
//получаем картинку
$arImages = array();
$entry_imgs = $doc_detail->find('.slides ul li a');
foreach ($entry_imgs as $row_img) {
$ent_img = pq($row_img);
$url_img = $ent_img->attr('href');
$arFile = CFile::MakeFileArray('https://hypower.ru'.$url_img);
$arFile["MODULE_ID"] = "main";
$fid = CFile::SaveFile($arFile, $path_img, false, false, 'img');
$path = CFile::GetPath($fid);
$arUrlImg = explode('/',$path);
unset($arUrlImg[1]);
$arImages[] = implode('/',$arUrlImg);
//print_r($arImages);//exit;
}
//запись в файл
$sheet->setCellValue("A".$i, $i);
$sheet->setCellValue("B".$i, $path_img);
$sheet->setCellValue("C".$i, $article);
$sheet->getColumnDimension("D")->setWidth(35);
$sheet->setCellValue("D".$i, $title);
//запись описания в файл
$sheet->getColumnDimension("E")->setWidth(100);
$sheet->getStyle("E".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("E".$i, $descr);
//запись свойств в файл
$sheet->getColumnDimension("F")->setWidth(100);
$sheet->getStyle("F".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("F".$i, $strToFile);
$sheet->getColumnDimension("G")->setWidth(50);
$sheet->getStyle("G".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("G".$i, implode(';',$arImages));
//$i++;
//break;
}
// проверяем есть ли постраничная навигация
$entry_pages= $doc_subSubsec->find('.module-pagination ul a');
/* echo '<pre>';
print_r('проверяем постраничную навигацию https://hypower.ru'.$url_subSubsection);
foreach ($entry_pages as $row_page) {
$ent_page = pq($row_page);
$url_page = $ent_page->attr('href');
print_r($url_page);
//print_r(pq($entry_pages[0])->attr('href'));
}
echo '</pre>'; */
echo '<pre>';
print_r('подраздел с товарами');
print_r('https://hypower.ru'.$url_subSubsection);
echo '</pre>';
//если есть постраничный вывод
if(pq($entry_pages[0])->attr('href')){
foreach ($entry_pages as $row_page) {
$ent_page = pq($row_page);
$url_page = $ent_page->attr('href');
$doc_subSubsec = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_page));
$entry_subSubsec = $doc_subSubsec->find('.item_info--top_block a');
foreach ($entry_subSubsec as $row_subSubsec) {
$url_item = trim(pq($row_subSubsec)->attr('href'));
$doc_detail = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_item));
//получаем название товра
$entry_title = $doc_detail->find('.top_info h1');
$title = trim(pq($entry_title)->text());
if(in_array($title, $arrName)){
continue;
}
$i = $i+1;
$arrName[$i] = $title;
/* echo '<pre>';
print_r($url_item);
echo '</pre>'; */
//получаем артикул товра
//$arTitle = explode(" ", $title);
//$article = $arTitle[0];
//получаем описание
$entry_text = $doc_detail->find('.tabs_section .row div.col-md-12');
$entry_text->find('h4')->remove();
//$entry_text->find('img')->remove();
//$entry_text->find('p[style="text-align: center;"]')->remove();
$entry_text->find('.low-price-mobile')->remove();
$descr = pq($entry_text)->html();
if($deleteTag){
//$descr = strip_tags($descr);
$descr = strip_tags($descr, '<br>');
$descr = str_replace('<br>','',$descr);
$descr = str_replace(' ','',$descr);
}else{
$descr = str_replace('/upload','https://hypower.ru/upload',$descr);
}
//запись описания в файл
/* $sheet->getColumnDimension("E")->setWidth(100);
$sheet->getStyle("E".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("E".$i, $descr); */
//получаем характеристики
$arProps = array();
$entry_prop = $doc_detail->find('.props_list tr');
$jPr = 0;
$strToFile = '';
foreach ($entry_prop as $row_prop) {
$ent_prop = pq($row_prop);
$entNameProp = $ent_prop->find('.char_name span[itemprop="name"]');
$arProps[$jPr]['name'] = trim(pq($entNameProp)->text());
$entValueProp = $ent_prop->find('.char_value span[itemprop="value"]');
$arProps[$jPr]['value'] = trim(pq($entValueProp)->text());
//получаем артикул товра
//$arTitle = explode(" ", $title);
if($arProps[$jPr]['name'] == 'Артикул Ref.'){
$article = $arProps[$jPr]['value'];
}
$strToFile .= $arProps[$jPr]['name'].' : '.$arProps[$jPr]['value']. ';';
$jPr++;
}
//получаем картинку
$arImages = array();
$entry_imgs = $doc_detail->find('.slides ul li a');
foreach ($entry_imgs as $row_img) {
$ent_img = pq($row_img);
$url_img = $ent_img->attr('href');
$arFile = CFile::MakeFileArray('https://hypower.ru'.$url_img);
$arFile["MODULE_ID"] = "main";
$fid = CFile::SaveFile($arFile, $path_img, false, false, 'img');
$path = CFile::GetPath($fid);
$arUrlImg = explode('/',$path);
unset($arUrlImg[1]);
$arImages[] = implode('/',$arUrlImg);
//print_r($arImages);//exit;
}
//запись в файл
$sheet->setCellValue("A".$i, $i);
$sheet->setCellValue("B".$i, $path_img);
$sheet->setCellValue("C".$i, $article);
$sheet->getColumnDimension("D")->setWidth(35);
$sheet->setCellValue("D".$i, $title);
//запись описания в файл
$sheet->getColumnDimension("E")->setWidth(100);
$sheet->getStyle("E".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("E".$i, $descr);
//запись свойств в файл
$sheet->getColumnDimension("F")->setWidth(100);
$sheet->getStyle("F".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("F".$i, $strToFile);
$sheet->getColumnDimension("G")->setWidth(100);
$sheet->getStyle("G".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("G".$i, implode(';',$arImages));
//$i++;
//break;
}
echo '<pre>';
print_r('попали на постраничную навигацию');
print_r('https://hypower.ru'.$url_page);
echo '</pre>';
//break;
}
}/* else{
} */
//break;
}
//break;
//}-------------------------
//}
$objWriter = new PHPExcel_Writer_Excel2007($xls);
$objWriter->save(__DIR__ . '/hypower.xlsx');
}
ParseToExcel($catalogUrl1);
function ParseToExcelProd($catalogUrl,$deleteTag = false){
$path_img = 'frezy_po_metallu';
//$filename = 'hypower.xls';
$filename = 'hypower.xlsx';
$arrName = array();
if(file_exists($filename)){
$xls = PHPExcel_IOFactory::load($filename);
$worksheet = $xls->getActiveSheet();
$lastRow = $worksheet->getHighestRow();
$sheet = $xls->getActiveSheet();
$i = $lastRow;
/* echo '<pre>';
print_r($lastRow);
echo '</pre>'; */
}else{
$xls = new PHPExcel();
$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
$sheet->setTitle('Товары');
// Формат
$sheet->getPageSetup()->SetPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Ориентация
// ORIENTATION_PORTRAIT — книжная
// ORIENTATION_LANDSCAPE — альбомная
$sheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
// Поля
$sheet->getPageMargins()->setTop(1);
$sheet->getPageMargins()->setRight(0.75);
$sheet->getPageMargins()->setLeft(0.75);
$sheet->getPageMargins()->setBottom(1);
$sheet->setCellValue("A1", "номер позиции");
$sheet->setCellValue("B1", "номер папки с фото (совпадает с артикулом)");
$sheet->setCellValue("C1", "Артикул");
$sheet->setCellValue("D1", "Наименование");
$sheet->setCellValue("E1", "Описание");
$sheet->setCellValue("F1", "Характеристики");
$sheet->setCellValue("G1", "Картинка");
$i=1;
//print_r('no');
}
//exit;
//создаем документ
//берем основную страницу каталога и переходим в подкатегории
/* $doc_sec = phpQuery::newDocument(file_get_contents($catalogUrl));
$entry_sec = $doc_sec->find('.section_block .item a');
foreach ($entry_sec as $row_sec) {
$ent_sec = pq($row_sec);
$url_subsection = $ent_sec->attr('href'); */
//$doc_subsec = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_subsection));
/* $doc_subsec = phpQuery::newDocument(file_get_contents($catalogUrl));
$entry_subsec = $doc_subsec->find('.section_block .item div.name a');
foreach ($entry_subsec as $row_subsec) {
$ent_subsec = pq($row_subsec);
$url_subSubsection = $ent_subsec->attr('href'); */
//получаем страницу с товарами
$doc_subSubsec = phpQuery::newDocument(file_get_contents($catalogUrl));
//если нет постраничного вывода или первая страница
$entry_subSubsec = $doc_subSubsec->find('.item_info--top_block a');
foreach ($entry_subSubsec as $row_subSubsec) {
//$sheet->setCellValue("A".$i, $i);
$url_item = trim(pq($row_subSubsec)->attr('href'));
$doc_detail = phpQuery::newDocument(file_get_contents('https://hypower.ru'.$url_item));
//получаем название товра
$entry_title = $doc_detail->find('.top_info h1');
$title = trim(pq($entry_title)->text());
if(in_array($title, $arrName)){
continue;
}
$i = $i+1;
$arrName[$i] = $title;
echo '<pre>';
print_r($title);
echo '</pre>';//exit;
//получаем артикул товра
//$arTitle = explode(" ", $title);
//$article = $arTitle[0];
//получаем описание
$entry_text = $doc_detail->find('.tabs_section .row div.col-md-12');
$entry_text->find('h4')->remove();
//$entry_text->find('img')->remove();
//$entry_text->find('p[style="text-align: center;"]')->remove();
$entry_text->find('.low-price-mobile')->remove();
$descr = pq($entry_text)->html();
if($deleteTag){
//$descr = strip_tags($descr);
$descr = strip_tags($descr, '<br>');
$descr = str_replace('<br>','',$descr);
$descr = str_replace(' ','',$descr);
}else{
$descr = str_replace('/upload','https://hypower.ru/upload',$descr);
}
//запись описания в файл
/* $sheet->getColumnDimension("E")->setWidth(100);
$sheet->getStyle("E".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("E".$i, $descr); */
//получаем характеристики
$arProps = array();
$entry_prop = $doc_detail->find('.props_list tr');
$jPr = 0;
$strToFile = '';
foreach ($entry_prop as $row_prop) {
$ent_prop = pq($row_prop);
$entNameProp = $ent_prop->find('.char_name span[itemprop="name"]');
$arProps[$jPr]['name'] = trim(pq($entNameProp)->text());
$entValueProp = $ent_prop->find('.char_value span[itemprop="value"]');
$arProps[$jPr]['value'] = trim(pq($entValueProp)->text());
//получаем артикул товра
//$arTitle = explode(" ", $title);
if($arProps[$jPr]['name'] == 'Артикул Ref.'){
$article = $arProps[$jPr]['value'];
}
$strToFile .= $arProps[$jPr]['name'].' : '.$arProps[$jPr]['value']. ';';
$jPr++;
}
//получаем картинку
$arImages = array();
$entry_imgs = $doc_detail->find('.slides ul li a');
foreach ($entry_imgs as $row_img) {
$ent_img = pq($row_img);
$url_img = $ent_img->attr('href');
$arFile = CFile::MakeFileArray('https://hypower.ru'.$url_img);
$arFile["MODULE_ID"] = "main";
$fid = CFile::SaveFile($arFile, $path_img, false, false, 'img');
$path = CFile::GetPath($fid);
$arUrlImg = explode('/',$path);
unset($arUrlImg[1]);
$arImages[] = implode('/',$arUrlImg);
//print_r($arImages);//exit;
}
//запись в файл
$sheet->setCellValue("A".$i, $i);
$sheet->setCellValue("B".$i, $path_img);
$sheet->setCellValue("C".$i, $article);
$sheet->getColumnDimension("D")->setWidth(35);
$sheet->setCellValue("D".$i, $title);
//запись описания в файл
$sheet->getColumnDimension("E")->setWidth(100);
$sheet->getStyle("E".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("E".$i, $descr);
//запись свойств в файл
$sheet->getColumnDimension("F")->setWidth(100);
$sheet->getStyle("F".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("F".$i, $strToFile);
$sheet->getColumnDimension("G")->setWidth(50);
$sheet->getStyle("G".$i)->getAlignment()->setWrapText(true);
$sheet->setCellValue("G".$i, implode(';',$arImages));
//$i++;
//break;
}
echo '<pre>';
print_r('подраздел с товарами');
print_r('https://hypower.ru'.$url_subSubsection);
echo '</pre>';
//break;
//}------------
//break;
//}-------------------------
//}
$objWriter = new PHPExcel_Writer_Excel2007($xls);
$objWriter->save(__DIR__ . '/hypower.xlsx');
}
//ParseToExcelProd($catalogUrl1);
?>
\ No newline at end of file
<?require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php");
error_reporting(0);
ini_set('display_errors', 0);
setlocale(LC_ALL, 'ru_RU');
date_default_timezone_set('Europe/Moscow');
header('Content-type: text/html; charset=utf-8');
require('PHPExcel/PHPExcel.php');
use Bitrix\Main\Loader;
Loader::includeModule('main');
$filename = $_SERVER['DOCUMENT_ROOT'].'/hypower.xlsx';
$result = array();
// получаем тип файла (xls, xlsx), чтобы правильно его обработать
$file_type = PHPExcel_IOFactory::identify( $filename );
// создаем объект для чтения
$objReader = PHPExcel_IOFactory::createReader( $file_type );
$objPHPExcel = $objReader->load( $filename ); // загружаем данные файла
$result = $objPHPExcel->getActiveSheet()->toArray(); // выгружаем данные
$el = new CIBlockElement;
// список значений свойства Тип резки
$arrPropCutter = array();
$property_enums = CIBlockPropertyEnum::GetList(Array("DEF"=>"DESC", "SORT"=>"ASC"), Array("IBLOCK_ID"=>40, "CODE"=>"CUTTER_TYPE"));
while($enum_fields = $property_enums->GetNext())
{
$arrPropCutter[$enum_fields["ID"]] = $enum_fields["VALUE"];
}
// список значений свойства Сопло
$arrPropNozzle = array();
$property_enums = CIBlockPropertyEnum::GetList(Array("DEF"=>"DESC", "SORT"=>"ASC"), Array("IBLOCK_ID"=>40, "CODE"=>"NOZZLE"));
while($enum_fields = $property_enums->GetNext())
{
$arrPropNozzle[$enum_fields["ID"]] = $enum_fields["VALUE"];
}
foreach($result as $key=>$line){
if($key>0){
// $line['4'] - описание
// $line['5'] - св-ва
// $line['6'] - картинки
//берем id товара
$productId = 0;
$arSelect = Array("ID", "NAME");
$arFilter = Array("IBLOCK_ID"=>40, "PROPERTY_CML2_ARTICLE"=>$line[2]);
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
while($ob = $res->GetNextElement())
{
$arFields = $ob->GetFields();
echo '<pre>';
print_r($arFields);
echo '</pre>';
$productId = $arFields['ID'];
}
$arLoadProductArray = array(
"IBLOCK_ID" => 40,
"DETAIL_TEXT_TYPE" =>"html",
"DETAIL_TEXT" => $line['4'],
);
//разбираем свойства
//$PROP = array();
$arrProp = explode(';', $line['5']);
foreach($arrProp as $prop){
$lineProp = explode(':', $prop);
$lineProp[0] = trim($lineProp[0]);
$lineProp[1] = trim($lineProp[1]);
switch ($lineProp[0]) {
case 'Подходит / совместим с':
CIBlockElement::SetPropertyValueCode($productId, "COMPATIBILITY", $lineProp[2]);
//$PROP[684] = $lineProp[2];
break;
case 'Система':
CIBlockElement::SetPropertyValueCode($productId, "SYSTEM", $lineProp[1]);
//$PROP[685] = $lineProp[1];
break;
case 'Артикул Ref.':
CIBlockElement::SetPropertyValueCode($productId, "ARTICLE", $lineProp[1]);
//$PROP[701] = $lineProp[1];
break;
case 'Сила тока, А':
CIBlockElement::SetPropertyValueCode($productId, "CURRENT", $lineProp[1]);
//$PROP[686] = $lineProp[1];
break;
case 'Применение':
CIBlockElement::SetPropertyValueCode($productId, "NOTE", $lineProp[1]);
//$PROP[687] = $lineProp[1];
break;
case 'Высота, мм':
CIBlockElement::SetPropertyValueCode($productId, "HEIGHT", $lineProp[1]);
//$PROP[690] = $lineProp[1];
break;
case 'Тип резака':
foreach($arrPropCutter as $key=>$cutter){
if($cutter == $lineProp[1]){
CIBlockElement::SetPropertyValueCode($productId, "CUTTER_TYPE", $key);
//$PROP[688] = $key;
}
}
break;
case 'Лазерная головка':
CIBlockElement::SetPropertyValueCode($productId, "LASER_HEAD", $lineProp[1]);
//$PROP[696] = $lineProp[1];
break;
case 'Длина кабеля, м':
CIBlockElement::SetPropertyValueCode($productId, "CABLE_LENGTH", $lineProp[1]);
//$PROP[689] = $lineProp[1];
break;
case 'Высота, мм':
CIBlockElement::SetPropertyValueCode($productId, "HEIGHT", $lineProp[1]);
//$PROP[690] = $lineProp[1];
break;
case 'Диаметр отверстия, мм':
CIBlockElement::SetPropertyValueCode($productId, "DIAMETER_HOLE", $lineProp[1]);
//$PROP[691] = $lineProp[1];
break;
case 'Резьба':
CIBlockElement::SetPropertyValueCode($productId, "CARVING", $lineProp[1]);
//$PROP[692] = $lineProp[1];
break;
case 'Сопло':
foreach($arrPropNozzle as $key=>$nozzle){
if($nozzle == $lineProp[1]){
CIBlockElement::SetPropertyValueCode($productId, "NOZZLE", $key);
//$PROP[693] = $key;
}
}
break;
case 'Материал':
CIBlockElement::SetPropertyValueCode($productId, "MATERIAL", $lineProp[1]);
//$PROP[694] = $lineProp[1];
break;
case 'Диаметр, мм':
CIBlockElement::SetPropertyValueCode($productId, "DIAMETER", $lineProp[1]);
//$PROP[695] = $lineProp[1];
break;
case 'Покрытие':
CIBlockElement::SetPropertyValueCode($productId, "COVERAGE", $lineProp[1]);
//$PROP[697] = $lineProp[1];
break;
case 'Тип линзы':
CIBlockElement::SetPropertyValueCode($productId, "LENS_TYPE", $lineProp[1]);
//$PROP[698] = $lineProp[1];
break;
case 'Допуск фокусного расстояния':
CIBlockElement::SetPropertyValueCode($productId, "FOCAL_LENGTH_TOLERANCE", $lineProp[1]);
//$PROP[699] = $lineProp[1];
break;
case 'Фокусное расстояние, мм':
CIBlockElement::SetPropertyValueCode($productId, "FOCAL_LENGTH", $lineProp[1]);
//$PROP[700] = $lineProp[1];
break;
case 'Артикул Hypower':
CIBlockElement::SetPropertyValueCode($productId, "ARTICLE_HYPOWER", $lineProp[1]);
//$PROP[703] = $lineProp[1];
break;
case 'Скорость резки, мм/мин':
CIBlockElement::SetPropertyValueCode($productId, "CUTTING_SPEED", $lineProp[1]);
//$PROP[704] = $lineProp[1];
break;
case 'Диапазон применения':
CIBlockElement::SetPropertyValueCode($productId, "APPLACATION_RANGE", $lineProp[1]);
//$PROP[702] = $lineProp[1];
break;
}
}
//разбираем картинки
/* $arImg = explode(';', $line['6']);
if(count($arImg) > 1){
foreach($arImg as $i=>$img){
if($i == 0){
$arLoadProductArray['DETAIL_PICTURE'] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].'/img_upload'.$img[0]);
$arLoadProductArray['PREVIEW_PICTURE'] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].'/img_upload'.$img[0]);
}else{
$PROP["679"]["n".($i-1)] = Array(
"VALUE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].'/img_upload'.$img)
);
}
}
}else{
$arLoadProductArray['PREVIEW_PICTURE'] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].'/img_upload'.$arImg[0]);
$arLoadProductArray['DETAIL_PICTURE'] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].'/img_upload'.$arImg[0]);
}
$arLoadProductArray[''] */
/* $arLoadProductArray = Array(
"MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем
"IBLOCK_SECTION" => false, // элемент лежит в корне раздела
"PROPERTY_VALUES"=> $PROP,
"NAME" => "Элемент",
"ACTIVE" => "Y", // активен
"PREVIEW_TEXT" => "текст для списка элементов",
"DETAIL_TEXT" => "текст для детального просмотра",
"DETAIL_PICTURE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/image.gif")
); */
$res = $el->Update($productId, $arLoadProductArray);
// echo '<pre>';
// print_r($productId);
// print_r($arLoadProductArray);
// echo '</pre>'; exit;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment