Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
tuls
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Кузнецова Людмила
tuls
Commits
5b1a4acf
Commit
5b1a4acf
authored
Jun 12, 2024
by
Кузнецова Людмила
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parsing
parents
Pipeline
#148
failed with stages
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
231 additions
and
0 deletions
+231
-0
parsing.php
parsing.php
+0
-0
properties_upload.php
properties_upload.php
+231
-0
No files found.
parsing.php
0 → 100644
View file @
5b1a4acf
This diff is collapsed.
Click to expand it.
properties_upload.php
0 → 100644
View file @
5b1a4acf
<?
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment