17if (!function_exists(
'__sortCSVOrder'))
19 function __sortCSVOrder(
$a, $b): int
21 if (
$a[
'SORT'] == $b[
'SORT'])
23 return (
$a[
'ID'] < $b[
'ID'] ? -1 : 1);
27 return (
$a[
'SORT'] < $b[
'SORT'] ? -1 : 1);
90 $arIBlockres = CIBlock::GetList(Array(
"sort"=>
"asc"), Array(
"ID"=>
$IBLOCK_ID,
'CHECK_PERMISSIONS' =>
'N'));
109 if (!isset($fields_type) || ($fields_type !=
"F" && $fields_type !=
"R"))
114 $csvFile->SetFieldsType($fields_type);
116 $first_names_r = (isset($first_names_r) && $first_names_r ==
'Y' ? true :
false);
117 $csvFile->SetFirstHeader($first_names_r);
120 $delimiter_r_char =
"";
121 if (isset($delimiter_r))
123 switch ($delimiter_r)
126 $delimiter_r_char =
"\t";
129 $delimiter_r_char =
",";
132 $delimiter_r_char =
" ";
135 $delimiter_r_char = (isset($delimiter_other_r)? mb_substr($delimiter_other_r, 0, 1) :
'');
138 $delimiter_r_char =
";";
143 if (mb_strlen($delimiter_r_char) != 1)
150 $csvFile->SetDelimiter($delimiter_r_char);
183 $bFieldsPres = (!empty($field_needed) && is_array($field_needed) && in_array(
'Y', $field_needed));
184 if ($bFieldsPres && (empty($field_code) || !is_array($field_code)))
186 $bFieldsPres =
false;
194 $tableLinksCount = 10;
195 for (
$i = 0, $intCount =
count($field_code);
$i < $intCount;
$i++)
197 if (mb_substr($field_code[
$i], 0, mb_strlen(
"CR_PRICE_")) ==
"CR_PRICE_" && isset($field_needed[
$i]) && $field_needed[
$i]==
"Y")
201 elseif (mb_substr($field_code[
$i], 0, mb_strlen(
"IP_PROP")) ==
"IP_PROP" && isset($field_needed[
$i]) && $field_needed[
$i]==
"Y")
206 if ($tableLinksCount>30)
211 $num_rows_writed = 0;
218 $arSortFields =
array();
219 $selectArray =
array(
"ID",
"IBLOCK_ID",
"IBLOCK_SECTION_ID");
220 $bNeedGroups =
false;
221 $bNeedPrices =
false;
222 $bNeedProducts =
false;
224 $arGroupProps =
array();
225 $arElementProps =
array();
226 $arFileProps =
array();
227 $arCatalogGroups =
array();
228 $arProductFields =
array();
229 $bNeedCounts =
false;
230 $arCountFields =
array();
231 $arValueCodes =
array();
232 $arNeedFields =
array();
236 $arAvailProdFields = explode(
",", $strAvailProdFields);
237 $arAvailProdFields_names =
array();
240 if (in_array($arOneCatalogAvailProdFields[
'value'],$arAvailProdFields))
242 $arAvailProdFields_names[$arOneCatalogAvailProdFields[
'value']] =
array(
243 "field" => $arOneCatalogAvailProdFields[
"field"],
244 "important" => $arOneCatalogAvailProdFields[
"important"],
246 $mxSelKey = array_search($arOneCatalogAvailProdFields[
'value'], $field_code);
247 if (!(
false === $mxSelKey || empty($field_needed[$mxSelKey]) ||
'Y' != $field_needed[$mxSelKey]))
249 $arSortFields[$arOneCatalogAvailProdFields[
'value']] =
array(
250 'CODE' => $arOneCatalogAvailProdFields[
'value'],
252 'SORT' => (!empty($field_num[$mxSelKey]) && 0 < intval($field_num[$mxSelKey]) ? intval($field_num[$mxSelKey]) : ($intCount+1)*10),
254 $selectArray[] = $arOneCatalogAvailProdFields[
"field"];
259 if (isset($arOneCatalogAvailProdFields))
260 unset($arOneCatalogAvailProdFields);
265 $mxSelKey = array_search(
'IP_PROP'.$arProp[
'ID'], $field_code);
266 if (!(
false === $mxSelKey || empty($field_needed[$mxSelKey]) ||
'Y' != $field_needed[$mxSelKey]))
268 $arSortFields[
'IP_PROP'.$arProp[
'ID']] =
array(
269 'CODE' =>
'IP_PROP'.$arProp[
'ID'],
271 'SORT' => (!empty($field_num[$mxSelKey]) && 0 < intval($field_num[$mxSelKey]) ? intval($field_num[$mxSelKey]) : ($intCount+1)*10),
274 $arElementProps[] = $arProp[
'ID'];
275 if (
'F' == $arProp[
'PROPERTY_TYPE'])
277 $arFileProps[] = $arProp[
'ID'];
279 $selectArray[] =
"PROPERTY_".$arProp[
'ID'];
285 $arElementProps = array_values(array_unique($arElementProps));
286 if (!empty($arFileProps))
287 $arFileProps = array_values(array_unique($arFileProps));
292 $arAvailGroupFields = explode(
",", $strAvailGroupFields);
293 $arAvailGroupFields_names =
array();
296 if (in_array($arOneCatalogAvailGroupFields[
'value'],$arAvailGroupFields))
298 $arAvailGroupFields_names[$arOneCatalogAvailGroupFields[
'value']] =
array(
299 "field" => $arOneCatalogAvailGroupFields[
"field"],
300 "important" => $arOneCatalogAvailGroupFields[
"important"],
304 if (isset($arOneCatalogAvailGroupFields))
305 unset($arOneCatalogAvailGroupFields);
306 if (!empty($arAvailGroupFields_names))
308 $arAvailGroupFieldsList = array_keys($arAvailGroupFields_names);
311 foreach ($arAvailGroupFieldsList as &$strKey)
313 $mxSelKey = array_search($strKey.$i, $field_code);
314 if (!(
false === $mxSelKey || empty($field_needed[$mxSelKey]) ||
'Y' != $field_needed[$mxSelKey]))
316 $arSortFields[$strKey.$i] =
array(
317 'CODE' => $strKey.$i,
319 'SORT' => (!empty($field_num[$mxSelKey]) && 0 < intval($field_num[$mxSelKey]) ? intval($field_num[$mxSelKey]) : ($intCount+1)*10),
322 $arGroupProps[
$i][] = $strKey;
328 if (!empty($arGroupProps[
$i]))
329 $arGroupProps[
$i] = array_values(array_unique($arGroupProps[
$i]));
331 unset($arAvailGroupFieldsList);
338 $arAvailPriceFields = explode(
",", $strAvailPriceFields);
339 $arAvailPriceFields_names =
array();
342 if (in_array($arOneCatalogAvailPriceFields[
'value'],$arAvailPriceFields))
344 $arAvailPriceFields_names[$arOneCatalogAvailPriceFields[
'value']] =
array(
345 "field" => $arOneCatalogAvailPriceFields[
"field"],
346 "important" => $arOneCatalogAvailPriceFields[
"important"]
349 $mxSelKey = array_search($arOneCatalogAvailPriceFields[
'value'], $field_code);
350 if (!(
false === $mxSelKey || empty($field_needed[$mxSelKey]) ||
'Y' != $field_needed[$mxSelKey]))
352 $arSortFields[$arOneCatalogAvailPriceFields[
'value']] =
array(
353 'CODE' => $arOneCatalogAvailPriceFields[
'value'],
355 'SORT' => (!empty($field_num[$mxSelKey]) && 0 < intval($field_num[$mxSelKey]) ? intval($field_num[$mxSelKey]) : ($intCount+1)*10),
357 $bNeedProducts =
true;
358 $arProductFields[] = $arOneCatalogAvailPriceFields[
'value'];
359 $selectArray[] =
"CATALOG_".$arOneCatalogAvailPriceFields[
'field'];
364 if (isset($arOneCatalogAvailPriceFields))
365 unset($arOneCatalogAvailPriceFields);
367 $arProductFields = array_values(array_unique($arProductFields));
371 $arAvailCountFields = explode(
",", $strAvailCountFields);
372 $arAvailCountFields_names =
array();
375 if (in_array($arOneCatalogAvailQuantityFields[
'value'], $arAvailCountFields))
377 $arAvailCountFields_names[$arOneCatalogAvailQuantityFields[
'value']] =
array(
378 "field" => $arOneCatalogAvailQuantityFields[
"field"],
379 "important" => $arOneCatalogAvailQuantityFields[
"important"]
381 $mxSelKey = array_search($arOneCatalogAvailQuantityFields[
'value'], $field_code);
382 if (!(
false === $mxSelKey || empty($field_needed[$mxSelKey]) ||
'Y' != $field_needed[$mxSelKey]))
384 $arSortFields[$arOneCatalogAvailQuantityFields[
'value']] =
array(
385 'CODE' => $arOneCatalogAvailQuantityFields[
'value'],
387 'SORT' => (!empty($field_num[$mxSelKey]) && 0 < intval($field_num[$mxSelKey]) ? intval($field_num[$mxSelKey]) : ($intCount+1)*10),
390 $arCountFields[] = $arOneCatalogAvailQuantityFields[
'value'];
395 if (isset($arOneCatalogAvailQuantityFields))
396 unset($arOneCatalogAvailQuantityFields);
401 $arCurList =
array();
402 while ($lcur_res = $lcur->Fetch())
404 if (in_array($lcur_res[
"CURRENCY"],
$arVal))
406 $arCurList[] = $lcur_res[
"CURRENCY"];
410 $arPriceList =
array();
411 if (!empty($arCurList))
413 foreach ($field_code as $mxSelKey => $strOneFieldsCode)
415 if (0 == strncmp($strOneFieldsCode,
"CR_PRICE_", 9))
417 if (!(empty($field_needed[$mxSelKey]) ||
'Y' != $field_needed[$mxSelKey]))
419 $arTempo = explode(
'_', mb_substr($strOneFieldsCode, 9));
420 $arTempo[0] = intval($arTempo[0]);
424 $arPriceList[$arTempo[0]] = $arTempo[1];
425 $arSortFields[
'CR_PRICE_'.$arTempo[0].
'_'.$arTempo[1]] =
array(
426 'CODE' =>
'CR_PRICE_'.$arTempo[0].
'_'.$arTempo[1],
428 'SORT' => (!empty($field_num[$mxSelKey]) && 0 < intval($field_num[$mxSelKey]) ? intval($field_num[$mxSelKey]) : ($intCount+1)*10),
430 $selectArray[] =
"CATALOG_GROUP_".$arTempo[0];
440 $bNeedCounts =
false;
441 $arCountFields =
array();
444 uasort($arSortFields,
'__sortCSVOrder');
446 $arNeedFields = array_keys($arSortFields);
448 if ($first_line_names)
454 while ($res1 =
$res->Fetch())
456 $arResSections =
array();
461 while ($reseg1 = $reseg->Fetch())
463 if (0 < intval($reseg1[
'ADDITIONAL_PROPERTY_ID']))
466 while ($arSection = $sections_path->Fetch())
468 $arResSectionTmp =
array();
469 foreach ($arAvailGroupFields_names as
$key => $value)
471 $arResSectionTmp[
$key] = $arSection[
$value[
"field"]];
473 $arResSections[$indreseg][] = $arResSectionTmp;
477 if (empty($arResSections))
478 $arResSections[0] =
array();
482 $arResSections[0] =
array();
485 for ($inds = 0, $intSectCount =
count($arResSections); $inds < $intSectCount; $inds++)
487 $arResFields =
array();
488 for (
$i = 0, $intNFCount =
count($arNeedFields);
$i < $intNFCount;
$i++)
491 if (
is_set($arAvailProdFields_names, $arNeedFields[
$i]))
494 $arResFields[
$i] = $res1[$arAvailProdFields_names[$arNeedFields[
$i]][
"field"]];
495 if ($arNeedFields[
$i]==
"IE_PREVIEW_PICTURE" || $arNeedFields[
$i]==
"IE_DETAIL_PICTURE")
497 if (intval($arResFields[
$i])>0)
500 if (
$z = $db_z->Fetch())
502 $arResFields[
$i] =
$z[
"FILE_NAME"];
507 $arResFields[
$i] =
"";
514 if (!$bFieldOut &&
is_set($arAvailPriceFields_names, $arNeedFields[
$i]))
517 $arResFields[
$i] = $res1[
"CATALOG_".$arAvailPriceFields_names[$arNeedFields[
$i]][
"field"]];
520 if (!$bFieldOut &&
is_set($arAvailCountFields_names, $arNeedFields[
$i]))
523 $arResFields[
$i] = $res1[
"CATALOG_".$arAvailCountFields_names[$arNeedFields[
$i]][
"field"]];
529 if (mb_substr($arNeedFields[
$i], 0, mb_strlen(
"IP_PROP")) ==
"IP_PROP")
531 $strTempo = mb_substr($arNeedFields[
$i], mb_strlen(
"IP_PROP"));
532 if (!empty($arFileProps) && in_array($strTempo,$arFileProps))
535 if (0 < intval($res1[
"PROPERTY_".$strTempo.
"_VALUE"]))
537 $arFile = CFile::GetFileArray($res1[
"PROPERTY_".$strTempo.
"_VALUE"]);
538 if (is_array($arFile))
539 $valueTmp = $arFile[
'SRC'];
541 $arResFields[
$i] = $valueTmp;
545 $arResFields[
$i] = $res1[
"PROPERTY_".$strTempo.
"_VALUE"];
551 $sPriceTmp = mb_substr($arNeedFields[
$i], mb_strlen(
"CR_PRICE_"));
552 $arPriceTmp = explode(
"_", $sPriceTmp);
554 if ($res1[
"CATALOG_CURRENCY_".intval($arPriceTmp[0])] <>
''
555 && $res1[
"CATALOG_CURRENCY_".intval($arPriceTmp[0])]!=$arPriceTmp[1])
557 $arResFields[
$i] = Round(
CCurrencyRates::ConvertCurrency($res1[
"CATALOG_PRICE_".intval($arPriceTmp[0])], $res1[
"CATALOG_CURRENCY_".intval($arPriceTmp[0])], $arPriceTmp[1]), 2);
561 $arResFields[
$i] = $res1[
"CATALOG_PRICE_".intval($arPriceTmp[0])];
569 foreach ($arAvailGroupFields_names as
$key => $value)
571 if (
$key == mb_substr($arNeedFields[
$i], 0, mb_strlen(
$key))
572 && is_numeric(mb_substr($arNeedFields[
$i], mb_strlen(
$key))))
575 $arResFields[
$i] = $arResSections[$inds][intval(mb_substr($arNeedFields[
$i], mb_strlen(
$key)))][
$key];
596 if (isset($USER_TMP))
const BX_CATALOG_FILENAME_REG
const CATALOG_DEFAULT_EXPORT_PATH
static GetList($by='sort', $order='asc', $lang=LANGUAGE_ID)
static ConvertCurrency($valSum, $curFrom, $curTo, $valDate="")
static GetElementGroups($ID, $bElementOnly=false, $arSelect=array())
static GetList($arOrder=Array(), $arFilter=Array())
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
static getDefaultSettings($type, $extFormat=false)
static getSettingsFields($type, $extFormat=false)
static GetByID($fileId, $realId=false)
static GetList($arOrder=array("SORT"=>"ASC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
GetIBlockSectionPath($IBLOCK_ID, $SECTION_ID)
$_SERVER["DOCUMENT_ROOT"]
global $arCatalogAvailPriceFields
global $defCatalogAvailValueFields
global $arCatalogAvailQuantityFields
global $defCatalogAvailProdFields
global $defCatalogAvailQuantityFields
global $arCatalogAvailProdFields
global $defCatalogAvailCurrencies
global $arCatalogAvailGroupFields
global $arCatalogAvailValueFields
global $defCatalogAvailPriceFields
global $defCatalogAvailGroupFields
if(!($arIBlock=$arIBlockres->Fetch())) $boolCatalog
if(!CCatalog::IsUserExists()) if(!function_exists( '__CSVArrayMultiply')) if(!function_exists('__CSVExportFile')) $strCatalogDefaultFolder
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Rel2Abs($curdir, $relpath)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"