33if (defined(
"CATALOG_EXPORT_NO_STEP") && CATALOG_EXPORT_NO_STEP ==
true)
53$SETUP_VARS_LIST =
'IBLOCK_ID,SITE_ID,V,XML_DATA,SETUP_SERVER_NAME,COMPANY_NAME,SETUP_FILE_NAME,USE_HTTPS,FILTER_AVAILABLE,DISABLE_REFERERS,EXPORT_CHARSET,MAX_EXECUTION_TIME,CHECK_PERMISSIONS';
68 Sale\DiscountCouponsManager::freezeCouponStorage();
72 'typePrefix',
'vendor',
'vendorCode',
'model',
73 'author',
'name',
'publisher',
'series',
'year',
74 'ISBN',
'volume',
'part',
'language',
'binding',
75 'page_extent',
'table_of_contents',
'performed_by',
'performance_type',
76 'storage',
'format',
'recording_length',
'artist',
'title',
'year',
'media',
77 'starring',
'director',
'originalName',
'country',
'aliases',
78 'description',
'sales_notes',
'promo',
'provider',
'tarifplan',
79 'xCategory',
'additional',
'worldRegion',
'region',
'days',
'dataTour',
80 'hotel_stars',
'room',
'meal',
'included',
'transport',
'price_min',
'price_max',
81 'options',
'manufacturer_warranty',
'country_of_origin',
'downloadable',
'adult',
'param',
82 'place',
'hall',
'hall_part',
'is_premiere',
'is_kids',
'date'
87 'vendor',
'vendorCode',
'sales_notes',
'manufacturer_warranty',
'country_of_origin',
90 'vendor.model' =>
array(
91 'typePrefix',
'vendor',
'vendorCode',
'model',
'sales_notes',
'manufacturer_warranty',
'country_of_origin',
95 'author',
'publisher',
'series',
'year',
'ISBN',
'volume',
'part',
'language',
'binding',
96 'page_extent',
'table_of_contents',
'sales_notes'
99 'author',
'publisher',
'series',
'year',
'ISBN',
'performed_by',
'performance_type',
100 'language',
'volume',
'part',
'format',
'storage',
'recording_length',
'table_of_contents'
102 'artist.title' =>
array(
103 'title',
'artist',
'director',
'starring',
'originalName',
'country',
'year',
'media',
'adult'
107if (!function_exists(
"yandex_replace_special"))
111 if (in_array($arg[0],
array(
""",
"&",
"<",
">")))
118if (!function_exists(
"yandex_text2xml"))
124 $text = preg_replace(
"/[\x1-\x8\xB-\xC\xE-\x1F]/",
"",
$text);
130if (!function_exists(
'yandex_get_value'))
132function yandex_get_value(
142 $bParam = (strncmp($param,
'PARAM_', 6) == 0);
146 $PROPERTY_CODE = $iblockProperty[
'CODE'];
147 if (!isset($arOffer[
'PROPERTIES'][$PROPERTY_CODE]) && !isset($arOffer[
'PROPERTIES'][$PROPERTY]))
150 isset($arOffer[
'PROPERTIES'][$PROPERTY_CODE])
151 ? $arOffer[
'PROPERTIES'][$PROPERTY_CODE]
152 : $arOffer[
'PROPERTIES'][$PROPERTY]
154 if ($arProperty[
'ID'] != $PROPERTY)
159 switch ($iblockProperty[
'PROPERTY_TYPE'])
162 if ($iblockProperty[
'MULTIPLE'] ==
'Y')
164 if (!empty($arProperty[
'~VALUE']))
167 foreach($arProperty[
"~VALUE"] as $oneValue)
169 $isArray = is_array($oneValue);
171 ($isArray && !empty($oneValue))
172 || (!$isArray && $oneValue !=
'')
178 array(
"VALUE" => $oneValue),
179 array(
'MODE' =>
'SIMPLE_TEXT'),
189 $isArray = is_array($arProperty[
'~VALUE']);
191 ($isArray && !empty($arProperty[
'~VALUE']))
192 || (!$isArray && $arProperty[
'~VALUE'] !=
'')
198 array(
"VALUE" => $arProperty[
"~VALUE"]),
199 array(
'MODE' =>
'SIMPLE_TEXT'),
206 if (!empty($arProperty[
'VALUE']))
208 $arCheckValue =
array();
209 if (!is_array($arProperty[
'VALUE']))
211 $arProperty[
'VALUE'] = (int)$arProperty[
'VALUE'];
212 if ($arProperty[
'VALUE'] > 0)
213 $arCheckValue[] = $arProperty[
'VALUE'];
217 foreach ($arProperty[
'VALUE'] as $intValue)
219 $intValue = (int)$intValue;
221 $arCheckValue[] = $intValue;
225 if (!empty($arCheckValue))
228 '@ID' => $arCheckValue
230 if ($iblockProperty[
'LINK_IBLOCK_ID'] > 0)
231 $filter[
'=IBLOCK_ID'] = $iblockProperty[
'LINK_IBLOCK_ID'];
234 'select' =>
array(
'ID',
'NAME'),
246 if (!empty($arProperty[
'VALUE']))
248 $arCheckValue =
array();
249 if (!is_array($arProperty[
'VALUE']))
251 $arProperty[
'VALUE'] = (int)$arProperty[
'VALUE'];
252 if ($arProperty[
'VALUE'] > 0)
253 $arCheckValue[] = $arProperty[
'VALUE'];
257 foreach ($arProperty[
'VALUE'] as $intValue)
259 $intValue = (int)$intValue;
261 $arCheckValue[] = $intValue;
265 if (!empty($arCheckValue))
268 '@ID' => $arCheckValue
270 if ($iblockProperty[
'LINK_IBLOCK_ID'] > 0)
271 $filter[
'=IBLOCK_ID'] = $iblockProperty[
'LINK_IBLOCK_ID'];
274 'select' =>
array(
'ID',
'NAME'),
286 if (!empty($arProperty[
'~VALUE']))
288 if (is_array($arProperty[
'~VALUE']))
289 $value .= implode(
', ', $arProperty[
'~VALUE']);
291 $value .= $arProperty[
'~VALUE'];
295 if (!empty($arProperty[
'VALUE']))
297 if (is_array($arProperty[
'VALUE']))
299 foreach ($arProperty[
'VALUE'] as $intValue)
301 $intValue = (int)$intValue;
304 if ($ar_file = CFile::GetFileArray($intValue))
306 if(mb_substr($ar_file[
"SRC"], 0, 1) ==
"/")
307 $strFile =
$options[
'PROTOCOL'].$options[
'SITE_NAME'].CHTTP::urnEncode($ar_file[
'SRC'],
'utf-8');
318 $arProperty[
'VALUE'] = (int)$arProperty[
'VALUE'];
319 if ($arProperty[
'VALUE'] > 0)
321 if ($ar_file = CFile::GetFileArray($arProperty[
'VALUE']))
323 if(mb_substr($ar_file[
"SRC"], 0, 1) ==
"/")
324 $strFile =
$options[
'PROTOCOL'].$options[
'SITE_NAME'].CHTTP::urnEncode($ar_file[
'SRC'],
'utf-8');
334 if ($bParam && $iblockProperty[
'WITH_DESCRIPTION'] ==
'Y')
337 $value = $arProperty[
'~VALUE'];
341 $value = is_array($arProperty[
'~VALUE']) ? implode(
', ', $arProperty[
'~VALUE']) : $arProperty[
'~VALUE'];
357 $strProperty .= $strProperty ?
"\n" :
"";
368 $strProperty .=
'<param name="'.yandex_text2xml($iblockProperty[
'NAME'],
$options).
'">'.
379 unset($iblockProperty);
386if (!function_exists(
'yandexPrepareItems'))
391 $descrTypeField =
'PREVIEW_TEXT_TYPE';
395 $descrTypeField =
$options[
'DESCRIPTION'].
'_TYPE';
398 foreach (array_keys($list) as $index)
400 $row = &$list[$index];
402 $row[
'DETAIL_PAGE_URL'] = (string)$row[
'DETAIL_PAGE_URL'];
403 if ($row[
'DETAIL_PAGE_URL'] !==
'')
406 foreach ($row as $field => $value)
408 if ($field ==
'PREVIEW_TEXT' || $field ==
'DETAIL_TEXT')
412 if (is_array($value))
414 if (preg_match(
"/[;&<>\"]/", $value))
417 $safeRow[$field] =
$value;
418 $safeRow[
'~'.$field] =
$value;
420 unset($field, $value);
422 if (isset($row[
'PARENT_ID']) && isset($parents[$row[
'PARENT_ID']]))
424 $safeRow[
'~DETAIL_PAGE_URL'] = str_replace(
425 array(
'#SERVER_NAME#',
'#SITE_DIR#',
'#PRODUCT_URL#'),
427 $safeRow[
'~DETAIL_PAGE_URL']
432 $safeRow[
'~DETAIL_PAGE_URL'] = str_replace(
433 array(
'#SERVER_NAME#',
'#SITE_DIR#'),
435 $safeRow[
'~DETAIL_PAGE_URL']
438 $row[
'DETAIL_PAGE_URL'] = \CIBlock::ReplaceDetailUrl($safeRow[
'~DETAIL_PAGE_URL'], $safeRow,
false,
'E');
442 if ($row[
'DETAIL_PAGE_URL'] ==
'')
443 $row[
'DETAIL_PAGE_URL'] =
'/';
445 $row[
'DETAIL_PAGE_URL'] = str_replace(
' ',
'%20', $row[
'DETAIL_PAGE_URL']);
447 $row[
'PICTURE'] =
false;
448 $row[
'DETAIL_PICTURE'] = (int)$row[
'DETAIL_PICTURE'];
449 $row[
'PREVIEW_PICTURE'] = (int)$row[
'PREVIEW_PICTURE'];
450 if ($row[
'DETAIL_PICTURE'] > 0 || $row[
'PREVIEW_PICTURE'] > 0)
452 $pictureFile =
CFile::GetFileArray($row[
'DETAIL_PICTURE'] > 0 ? $row[
'DETAIL_PICTURE'] : $row[
'PREVIEW_PICTURE']);
453 if (!empty($pictureFile))
455 if (strncmp($pictureFile[
'SRC'],
'/', 1) == 0)
456 $picturePath =
$options[
'PROTOCOL'].$options[
'SITE_NAME'].CHTTP::urnEncode($pictureFile[
'SRC'],
'utf-8');
458 $picturePath = $pictureFile[
'SRC'];
459 $row[
'PICTURE'] = $picturePath;
465 $row[
'DESCRIPTION'] =
'';
470 $row[$descrTypeField] ==
'html'
471 ? strip_tags(preg_replace_callback(
"'&[^;]*;'",
'yandex_replace_special', $row[
$descrField]))
472 : preg_replace_callback(
"'&[^;]*;'",
'yandex_replace_special', $row[
$descrField]),
490 $XML_DATA = unserialize(stripslashes($XML_DATA), [
'allowed_classes' =>
false]);
492if (!isset($XML_DATA) || !is_array($XML_DATA))
496if (isset($XML_DATA[
'TYPE']) && isset(
$formatList[$XML_DATA[
'TYPE']]))
503$fieldsExist = !empty($XML_DATA[
'XML_DATA']) && is_array($XML_DATA[
'XML_DATA']);
507 foreach ($XML_DATA[
'XML_DATA'] as
$key => $value)
509 if (
$key ==
'PARAMS')
511 if (is_array($value))
513 $value = (string)$value;
552 'DESCRIPTION' =>
'PREVIEW_TEXT'
554if (!empty($XML_DATA[
'COMMON_FIELDS']) && is_array($XML_DATA[
'COMMON_FIELDS']))
559 'ID',
'PROPERTY_TYPE',
'MULTIPLE',
'USER_TYPE'
563 'USE_DOMAIN' =>
true,
564 'REFERRER_SEPARATOR' =>
'?'
567 'USE_DOMAIN' =>
true,
568 'REFERRER_SEPARATOR' =>
'?'
585 array(
'SORT' =>
'ASC',
'NAME' =>
'ASC'),
586 array(
'IBLOCK_ID' =>
$IBLOCK_ID,
'ACTIVE' =>
'Y',
'CHECK_PERMISSIONS' =>
'N')
590 $arProp[
'ID'] = (int)$arProp[
'ID'];
591 $arProp[
'USER_TYPE'] = (string)$arProp[
'USER_TYPE'];
592 $arProp[
'CODE'] = (string)$arProp[
'CODE'];
593 if ($arProp[
'CODE'] ==
'')
594 $arProp[
'CODE'] = $arProp[
'ID'];
595 $arProp[
'LINK_IBLOCK_ID'] = (int)$arProp[
'LINK_IBLOCK_ID'];
596 $ar_iblock[
'PROPERTY'][$arProp[
'ID']] = $arProp;
611 'select' =>
array(
'LID',
'SERVER_NAME',
'SITE_NAME',
'DIR'),
622 $site[
'SITE_NAME'] = (string)
$site[
'SITE_NAME'];
623 if (
$site[
'SITE_NAME'] ===
'')
624 $site[
'SITE_NAME'] = (string)
Main\
Config\Option::get(
'main',
'site_name');
626 if (
$site[
'COMPANY_NAME'] ===
'')
627 $site[
'COMPANY_NAME'] = (string)
Main\
Config\Option::get(
'main',
'site_name');
631 if (
$site[
'SERVER_NAME'] ===
'')
633 $site[
'SERVER_NAME'] = (defined(
'SITE_SERVER_NAME')
635 : (string)
Main\
Config\Option::get(
'main',
'server_name')
638 if (
$site[
'SERVER_NAME'] ===
'')
655 Iblock\PropertyTable::TYPE_STRING,
656 Iblock\PropertyTable::TYPE_NUMBER,
657 Iblock\PropertyTable::TYPE_LIST,
658 Iblock\PropertyTable::TYPE_ELEMENT,
659 Iblock\PropertyTable::TYPE_SECTION
690 $rsProps = \CIBlockProperty::GetList(
691 array(
'SORT' =>
'ASC',
'NAME' =>
'ASC'),
696 $arProp[
'ID'] = (int)$arProp[
'ID'];
697 if (
$arOffers[
'SKU_PROPERTY_ID'] != $arProp[
'ID'])
699 $arProp[
'USER_TYPE'] = (string)$arProp[
'USER_TYPE'];
700 $arProp[
'CODE'] = (string)$arProp[
'CODE'];
701 if ($arProp[
'CODE'] ==
'')
702 $arProp[
'CODE'] = $arProp[
'ID'];
703 $arProp[
'LINK_IBLOCK_ID'] = (int)$arProp[
'LINK_IBLOCK_ID'];
705 $ar_iblock[
'OFFERS_PROPERTY'][$arProp[
'ID']] = $arProp;
729 unset($rsOfferIBlocks);
735 if (empty($XML_DATA[
'SKU_EXPORT']))
782 $arCatalog[
'CATALOG_TYPE'] == CCatalogSku::TYPE_FULL
783 ||
$arCatalog[
'CATALOG_TYPE'] == CCatalogSku::TYPE_PRODUCT
792 if ($arProperty[
'USER_TYPE'] ==
'')
795 $arUserType = \CIBlockProperty::GetUserType($arProperty[
'USER_TYPE']);
796 if (isset($arUserType[
'GetPublicViewHTML']))
802unset($arUserType,
$key, $arProperty);
810 foreach ($V as
$key => $value)
812 if (trim($value)==
"0")
826 $clearedValues =
array();
838 $clearedValues[] = (int)$row[
'ID'];
841 unset($clearedValues);
851if (!empty($XML_DATA[
'PRICE']))
853 $XML_DATA[
'PRICE'] = (int)$XML_DATA[
'PRICE'];
854 if ($XML_DATA[
'PRICE'] > 0)
856 $priceIterator = Catalog\GroupAccessTable::getList([
857 'select' => [
'CATALOG_GROUP_ID'],
858 'filter' => [
'=CATALOG_GROUP_ID' => $XML_DATA[
'PRICE'],
'=GROUP_ID' => 2]
860 $priceType = $priceIterator->fetch();
861 if (empty($priceType))
865 unset($priceType, $priceIterator);
882 $priceIterator = Catalog\GroupAccessTable::getList([
883 'select' => [
'CATALOG_GROUP_ID'],
884 'filter' => [
'=GROUP_ID' => 2],
885 'order' => [
'CATALOG_GROUP_ID' =>
'ASC']
887 while ($priceType = $priceIterator->fetch())
889 $priceTypeId = (int)$priceType[
'CATALOG_GROUP_ID'];
893 unset($priceType, $priceIterator);
899$usedProtocol = (isset($USE_HTTPS) && $USE_HTTPS ==
'Y' ?
'https://' :
'http://');
902$exportCharset = (isset($EXPORT_CHARSET) && is_string($EXPORT_CHARSET) ? $EXPORT_CHARSET :
'');
918if (!empty($XML_DATA[
'VAT_EXPORT']) && is_array($XML_DATA[
'VAT_EXPORT']))
936 'select' =>
array(
'ID',
'RATE'),
938 'order' =>
array(
'ID' =>
'ASC')
942 $row[
'ID'] = (int)$row[
'ID'];
943 $row[
'RATE'] = (float)$row[
'RATE'];
944 $index = $row[
'RATE'].
'%';
955 'SITE_NAME' =>
$site[
'SERVER_NAME'],
956 'SITE_DIR' =>
$site[
'DIR'],
958 'MAX_DESCRIPTION_LENGTH' => 3000
1001 if (!@fwrite($fp,
'<? $disableReferers = '.(
$disableReferers ?
'true' :
'false').
';'.
"\n"))
1010 fwrite($fp,
'if (!isset($_GET["referer1"]) || $_GET["referer1"] == "") $_GET["referer1"] = "yandext";'.
"\n");
1011 fwrite($fp,
'$strReferer1 = htmlspecialchars($_GET["referer1"]);'.
"\n");
1012 fwrite($fp,
'if (!isset($_GET["referer2"]) || $_GET["referer2"] == "") $_GET["referer2"] = "";'.
"\n");
1013 fwrite($fp,
'$strReferer2 = htmlspecialchars($_GET["referer2"]);'.
"\n");
1022 fwrite($fp,
'header("Content-Type: text/xml; charset='.
$itemOptions[
'CHARSET'].
'");'.
"\n");
1023 fwrite($fp,
'echo "<"."?xml version=\"1.0\" encoding=\"'.
$itemOptions[
'CHARSET'].
'\"?".">"?>');
1024 fwrite($fp,
"\n".
'<!DOCTYPE yml_catalog SYSTEM "shops.dtd">'.
"\n");
1025 fwrite($fp,
'<yml_catalog date="'.date(
"Y-m-d H:i").
'">'.
"\n");
1026 fwrite($fp,
'<shop>'.
"\n");
1029 '<name>'.
Main\
Text\Encoding::convertEncoding(
1036 '<company>'.
Main\
Text\Encoding::convertEncoding(
1042 fwrite($fp,
'<url>'.
$usedProtocol.htmlspecialcharsbx(
$site[
'SERVER_NAME']).
"</url>\n");
1043 fwrite($fp,
'<platform>1C-Bitrix</platform>'.
"\n");
1045 $strTmp =
'<currencies>'.
"\n";
1048 $currencyIterator = Currency\CurrencyTable::getList(
array(
1049 'select' =>
array(
'CURRENCY'),
1050 'filter' =>
array(
'=CURRENCY' =>
'RUR')
1052 if (
$currency = $currencyIterator->fetch())
1056 $arCurrencyAllowed =
array($RUR,
'USD',
'EUR',
'UAH',
'BYR',
'BYN',
'KZT');
1058 if (is_array($XML_DATA[
'CURRENCY']))
1060 foreach ($XML_DATA[
'CURRENCY'] as
$CURRENCY => $arCurData)
1062 if (in_array(
$CURRENCY, $arCurrencyAllowed))
1064 $strTmp .=
'<currency id="'.$CURRENCY.
'"'
1066 .($arCurData[
'plus'] > 0 ?
' plus="'.(int)$arCurData[
'plus'].
'"' :
'')
1074 $currencyIterator = Currency\CurrencyTable::getList(
array(
1075 'select' =>
array(
'CURRENCY',
'SORT'),
1076 'filter' =>
array(
'@CURRENCY' => $arCurrencyAllowed),
1077 'order' =>
array(
'SORT' =>
'ASC',
'CURRENCY' =>
'ASC')
1079 while (
$currency = $currencyIterator->fetch())
1083 $strTmp .=
"</currencies>\n";
1085 fwrite($fp, $strTmp);
1092 $intMaxSectionID = 0;
1097 $arSectionIDs =
array();
1098 $arAvailGroups =
array();
1104 $curLEFT_MARGIN = 0;
1105 $curRIGHT_MARGIN = 0;
1106 while ($section = $sectionIterator->Fetch())
1108 $section[
'ID'] = (int)$section[
'ID'];
1109 $section[
'IBLOCK_SECTION_ID'] = (int)$section[
'IBLOCK_SECTION_ID'];
1112 $curLEFT_MARGIN = (int)$section[
'LEFT_MARGIN'];
1113 $curRIGHT_MARGIN = (int)$section[
'RIGHT_MARGIN'];
1114 $arSectionIDs[$section[
'ID']] = $section[
'ID'];
1116 $arAvailGroups[$section[
'ID']] =
array(
1117 'ID' => $section[
'ID'],
1118 'IBLOCK_SECTION_ID' => $section[
'IBLOCK_SECTION_ID'],
1119 'NAME' => $section[
'NAME']
1121 if ($intMaxSectionID < $section[
'ID'])
1122 $intMaxSectionID = $section[
'ID'];
1124 unset($section, $sectionIterator);
1128 '>LEFT_MARGIN' => $curLEFT_MARGIN,
1129 '<RIGHT_MARGIN' => $curRIGHT_MARGIN,
1130 'GLOBAL_ACTIVE' =>
'Y'
1133 array(
'LEFT_MARGIN' =>
'ASC'),
1136 array(
'ID',
'IBLOCK_SECTION_ID',
'NAME')
1138 while ($section = $sectionIterator->Fetch())
1140 $section[
'ID'] = (int)$section[
'ID'];
1141 $section[
'IBLOCK_SECTION_ID'] = (int)$section[
'IBLOCK_SECTION_ID'];
1142 $arAvailGroups[$section[
'ID']] = $section;
1143 if ($intMaxSectionID < $section[
'ID'])
1144 $intMaxSectionID = $section[
'ID'];
1146 unset($section, $sectionIterator);
1153 'GLOBAL_ACTIVE' =>
'Y'
1156 array(
'LEFT_MARGIN' =>
'ASC'),
1159 array(
'ID',
'IBLOCK_SECTION_ID',
'NAME')
1161 while ($section = $sectionIterator->Fetch())
1163 $section[
'ID'] = (int)$section[
'ID'];
1164 $section[
'IBLOCK_SECTION_ID'] = (int)$section[
'IBLOCK_SECTION_ID'];
1165 $arAvailGroups[$section[
'ID']] = $section;
1166 $arSectionIDs[$section[
'ID']] = $section[
'ID'];
1167 if ($intMaxSectionID < $section[
'ID'])
1168 $intMaxSectionID = $section[
'ID'];
1170 unset($section, $sectionIterator);
1173 foreach ($arAvailGroups as $value)
1174 $strTmpCat .=
'<category id="'.$value[
'ID'].
'"'.(
$value[
'IBLOCK_SECTION_ID'] > 0 ?
' parentId="'.$value[
'IBLOCK_SECTION_ID'].
'"' :
'').
'>'.
yandex_text2xml($value[
'NAME'],
$itemOptions).
'</category>'.
"\n";
1177 $intMaxSectionID += 100000000;
1179 fwrite($fp,
"<categories>\n");
1180 fwrite($fp, $strTmpCat);
1184 $boolNeedRootSection =
false;
1206 $saleDiscountOnly =
false;
1207 $calculationConfig = [
1209 'USE_DISCOUNTS' =>
true,
1210 'RESULT_WITH_VAT' =>
true,
1215 $saleDiscountOnly = (string)
Main\
Config\Option::get(
'sale',
'use_sale_discount_only') ==
'Y';
1216 if ($saleDiscountOnly)
1217 $calculationConfig[
'PRECISION'] = (int)
Main\
Config\Option::get(
'sale',
'value_precision');
1220 unset($calculationConfig);
1224 $itemFields =
array(
1225 'ID',
'IBLOCK_ID',
'IBLOCK_SECTION_ID',
'NAME',
1227 'AVAILABLE',
'TYPE',
'VAT_ID',
'VAT_INCLUDED'
1229 $offerFields =
array(
1230 'ID',
'IBLOCK_ID',
'IBLOCK_SECTION_ID',
'NAME',
1232 'AVAILABLE',
'TYPE',
'VAT_ID',
'VAT_INCLUDED'
1235 $allowedTypes =
array();
1239 $allowedTypes =
array(
1240 Catalog\ProductTable::TYPE_PRODUCT =>
true,
1241 Catalog\ProductTable::TYPE_SET =>
true
1245 $allowedTypes =
array(
1246 Catalog\ProductTable::TYPE_OFFER =>
true
1250 $allowedTypes =
array(
1251 Catalog\ProductTable::TYPE_PRODUCT =>
true,
1252 Catalog\ProductTable::TYPE_SET =>
true,
1253 Catalog\ProductTable::TYPE_SKU =>
true
1257 $allowedTypes =
array(
1258 Catalog\ProductTable::TYPE_SKU =>
true
1266 $filter[
'INCLUDE_SUBSECTIONS'] =
'Y';
1267 $filter[
'SECTION_ID'] = $arSectionIDs;
1275 $offersFilter =
array(
'ACTIVE' =>
'Y',
'ACTIVE_DATE' =>
'Y');
1277 $offersFilter[
'AVAILABLE'] =
'Y';
1280 if (isset($allowedTypes[
Catalog\ProductTable::TYPE_SKU]))
1287 $strExportKey =
'!';
1288 $strExportKey .=
'PROPERTY_'.$arSKUExport[
'SKU_PROP_COND'][
'PROP_ID'];
1291 $offersFilter[$strExportKey] = $mxValues;
1297 if (isset($CUR_ELEMENT_ID) && $CUR_ELEMENT_ID > 0)
1298 $filter[
'>ID'] = $CUR_ELEMENT_ID;
1300 $existItems =
false;
1302 $itemIdsList =
array();
1305 $skuIdsList =
array();
1306 $simpleIdsList =
array();
1309 array(
'ID' =>
'ASC'),
1317 $finalExport =
false;
1320 $id = (int)$row[
'ID'];
1321 $CUR_ELEMENT_ID = $id;
1323 $row[
'TYPE'] = (int)$row[
'TYPE'];
1324 $elementType = $row[
'TYPE'];
1325 if (!isset($allowedTypes[$elementType]))
1328 $row[
'SECTIONS'] =
array();
1330 $row[
'PROPERTIES'] =
array();
1331 $row[
'PRICES'] =
array();
1334 $itemIdsList[$id] = $id;
1336 if ($elementType ==
Catalog\ProductTable::TYPE_SKU)
1337 $skuIdsList[$id] = $id;
1339 $simpleIdsList[$id] = $id;
1347 foreach (array_chunk($itemIdsList, 500) as $pageIds)
1350 'select' =>
array(
'IBLOCK_ELEMENT_ID',
'IBLOCK_SECTION_ID'),
1351 'filter' =>
array(
'@IBLOCK_ELEMENT_ID' => $pageIds,
'==ADDITIONAL_PROPERTY_ID' =>
null),
1352 'order' =>
array(
'IBLOCK_ELEMENT_ID' =>
'ASC')
1356 $id = (int)$row[
'IBLOCK_ELEMENT_ID'];
1359 unset($sectionId, $id);
1369 \CIBlockElement::GetPropertyValuesArray(
1373 'ID' => $itemIdsList,
1381 if ($needDiscountCache)
1383 foreach ($itemIdsList as $id)
1390 foreach ($itemIdsList as $id)
1396 foreach ($itemIdsList as $id)
1398 if (empty(
$items[$id][
'PROPERTIES']))
1400 foreach (array_keys(
$items[$id][
'PROPERTIES']) as $index)
1402 $propertyId =
$items[$id][
'PROPERTIES'][$index][
'ID'];
1404 unset(
$items[$id][
'PROPERTIES'][$index]);
1406 unset($propertyId, $index);
1412 if ($needDiscountCache)
1418 if (!empty($skuIdsList))
1420 $offerPropertyFilter =
array();
1427 $offers = \CCatalogSku::getOffersList(
1432 $offerPropertyFilter,
1435 unset($offerPropertyFilter);
1437 if (!empty($offers))
1439 $offerLinks =
array();
1440 $offerIdsList =
array();
1441 $parentsUrl =
array();
1442 foreach (array_keys($offers) as $productId)
1444 unset($skuIdsList[$productId]);
1447 foreach (array_keys($offers[$productId]) as $offerId)
1449 $productOffer = $offers[
$productId][$offerId];
1450 $productOffer[
'VAT_ID'] = (int)$productOffer[
'VAT_ID'];
1451 if ($productOffer[
'VAT_ID'] == 0)
1454 $productOffer[
'PRICES'] =
array();
1455 if ($needDiscountCache)
1459 $productOffer[
'PROPERTIES'] =
array();
1463 if (!empty($productOffer[
'PROPERTIES']))
1465 foreach (array_keys($productOffer[
'PROPERTIES']) as $index)
1467 $propertyId = $productOffer[
'PROPERTIES'][$index][
'ID'];
1469 unset($productOffer[
'PROPERTIES'][$index]);
1471 unset($propertyId, $index);
1475 unset($productOffer);
1478 $offerIdsList[$offerId] = $offerId;
1482 if (!empty($offerIdsList))
1484 yandexPrepareItems($offerLinks, $parentsUrl,
$itemOptions);
1486 foreach (array_chunk($offerIdsList, 500) as $pageIds)
1488 if ($needDiscountCache)
1502 '@PRODUCT_ID' => $pageIds,
1505 '<=QUANTITY_FROM' => 1,
1506 '=QUANTITY_FROM' => null
1510 '>=QUANTITY_TO' => 1,
1511 '=QUANTITY_TO' => null
1519 $iterator = Catalog\PriceTable::getList([
1520 'select' => [
'ID',
'PRODUCT_ID',
'CATALOG_GROUP_ID',
'PRICE',
'CURRENCY'],
1521 'filter' => $priceFilter
1526 $id = (int)$price[
'PRODUCT_ID'];
1527 $priceTypeId = (int)$price[
'CATALOG_GROUP_ID'];
1528 $offerLinks[$id][
'PRICES'][$priceTypeId] = $price;
1529 unset($priceTypeId, $id);
1533 if ($saleDiscountOnly)
1543 unset($parentsUrl, $offerIdsList, $offerLinks);
1547 if (!empty($skuIdsList))
1549 foreach ($skuIdsList as $id)
1552 unset($itemIdsList[$id]);
1558 if (!empty($simpleIdsList))
1560 foreach (array_chunk($simpleIdsList, 500) as $pageIds)
1567 '@PRODUCT_ID' => $pageIds,
1570 '<=QUANTITY_FROM' => 1,
1571 '=QUANTITY_FROM' => null
1575 '>=QUANTITY_TO' => 1,
1576 '=QUANTITY_TO' => null
1584 $iterator = Catalog\PriceTable::getList([
1585 'select' => [
'ID',
'PRODUCT_ID',
'CATALOG_GROUP_ID',
'PRICE',
'CURRENCY'],
1586 'filter' => $priceFilter
1591 $id = (int)$price[
'PRODUCT_ID'];
1592 $priceTypeId = (int)$price[
'CATALOG_GROUP_ID'];
1593 $items[$id][
'PRICES'][$priceTypeId] = $price;
1594 unset($priceTypeId, $id);
1598 if ($saleDiscountOnly)
1613 foreach ($itemIdsList as $id)
1615 $CUR_ELEMENT_ID = $id;
1619 if (!empty($row[
'SECTIONS']))
1621 foreach ($row[
'SECTIONS'] as $sectionId)
1623 if (!isset($arAvailGroups[$sectionId]))
1631 $boolNeedRootSection =
true;
1632 $row[
'CATEGORY_ID'] = $intMaxSectionID;
1634 if (!isset($row[
'CATEGORY_ID']))
1637 if ($row[
'TYPE'] ==
Catalog\ProductTable::TYPE_SKU && !empty($row[
'OFFERS']))
1640 $minOfferPrice =
null;
1642 foreach (array_keys($row[
'OFFERS']) as $offerId)
1644 if (empty($row[
'OFFERS'][$offerId][
'PRICES']))
1646 unset($row[
'OFFERS'][$offerId]);
1652 $minPriceCurrency =
'';
1655 $row[
'OFFERS'][$offerId][
'ID'],
1659 $row[
'OFFERS'][$offerId][
'PRICES'],
1664 if (!empty($calculatePrice))
1666 $minPrice = $calculatePrice[
'RESULT_PRICE'][
'DISCOUNT_PRICE'];
1667 $fullPrice = $calculatePrice[
'RESULT_PRICE'][
'BASE_PRICE'];
1668 $minPriceCurrency = $calculatePrice[
'RESULT_PRICE'][
'CURRENCY'];
1670 unset($calculatePrice);
1673 unset($row[
'OFFERS'][$offerId]);
1676 $row[
'OFFERS'][$offerId][
'RESULT_PRICE'] =
array(
1677 'MIN_PRICE' => $minPrice,
1678 'FULL_PRICE' => $fullPrice,
1679 'CURRENCY' => $minPriceCurrency
1681 if ($minOfferPrice ===
null || $minOfferPrice > $minPrice)
1683 $minOfferId = $offerId;
1684 $minOfferPrice = $minPrice;
1691 if ($minOfferId ===
null)
1692 $row[
'OFFERS'] =
array();
1694 $row[
'OFFERS'] =
array($minOfferId => $row[
'OFFERS'][$minOfferId]);
1696 if (empty($row[
'OFFERS']))
1699 foreach ($row[
'OFFERS'] as $offer)
1701 $available =
' available="'.($offer[
'AVAILABLE'] ==
'Y' ?
'true' :
'false').
'"';
1702 $itemsContent .=
'<offer id="'.$offer[
'ID'].
'"'.
$productFormat.$available.
">\n";
1707 $referer =
$offerUrlConfig[
'REFERRER_SEPARATOR'].
'r1=<?=$strReferer1; ?>&r2=<?=$strReferer2; ?>';
1709 $itemsContent .=
"<url>".($offerUrlConfig[
'USE_DOMAIN'] ?
$usedProtocol.$site[
'SERVER_NAME'] :
'').
htmlspecialcharsbx($offer[
'DETAIL_PAGE_URL']).$referer.
"</url>\n";
1712 $minPrice = $offer[
'RESULT_PRICE'][
'MIN_PRICE'];
1713 $fullPrice = $offer[
'RESULT_PRICE'][
'FULL_PRICE'];
1714 $itemsContent .=
"<price>".$minPrice.
"</price>\n";
1715 if ($minPrice < $fullPrice)
1716 $itemsContent .=
"<oldprice>".$fullPrice.
"</oldprice>\n";
1717 $itemsContent .=
"<currencyId>".$offer[
'RESULT_PRICE'][
'CURRENCY'].
"</currencyId>\n";
1719 $itemsContent .=
"<vat>".$vatList[$offer[
'VAT_ID']].
"</vat>\n";
1721 $itemsContent .=
"<categoryId>".$row[
'CATEGORY_ID'].
"</categoryId>\n";
1723 $picture = (!empty($offer[
'PICTURE']) ? $offer[
'PICTURE'] : $row[
'PICTURE']);
1724 if (!empty($picture))
1725 $itemsContent .=
"<picture>".$picture.
"</picture>\n";
1737 $itemsContent .=
"<name>".yandex_text2xml($offer[
'NAME'],
$itemOptions).
"</name>\n";
1740 $itemsContent .=
"<description>".
1741 ($offer[
'DESCRIPTION'] !==
'' ? $offer[
'DESCRIPTION'] : $row[
'DESCRIPTION']).
1749 $value = yandex_get_value(
1759 $value = yandex_get_value(
1769 $itemsContent .=
$value.
"\n";
1772 unset($paramKey, $prop_id);
1788 $value = yandex_get_value(
1798 $value = yandex_get_value(
1808 $itemsContent .=
$value.
"\n";
1830 $value = yandex_get_value(
1840 $value = yandex_get_value(
1850 $itemsContent .=
$value.
"\n";
1856 $itemsContent .=
'</offer>'.
"\n";
1860 elseif (isset($simpleIdsList[$id]) && !empty($row[
'PRICES']))
1862 $row[
'VAT_ID'] = (int)$row[
'VAT_ID'];
1863 if ($row[
'VAT_ID'] == 0)
1868 $minPriceCurrency =
'';
1880 if (!empty($calculatePrice))
1882 $minPrice = $calculatePrice[
'RESULT_PRICE'][
'DISCOUNT_PRICE'];
1883 $fullPrice = $calculatePrice[
'RESULT_PRICE'][
'BASE_PRICE'];
1884 $minPriceCurrency = $calculatePrice[
'RESULT_PRICE'][
'CURRENCY'];
1886 unset($calculatePrice);
1891 $available =
' available="'.($row[
'AVAILABLE'] ==
'Y' ?
'true' :
'false').
'"';
1892 $itemsContent .=
'<offer id="'.$row[
'ID'].
'"'.
$productFormat.$available.
">\n";
1897 $referer =
$itemUrlConfig[
'REFERRER_SEPARATOR'].
'r1=<?=$strReferer1; ?>&r2=<?=$strReferer2; ?>';
1899 $itemsContent .=
"<url>".($itemUrlConfig[
'USE_DOMAIN'] ?
$usedProtocol.$site[
'SERVER_NAME'] :
'').
htmlspecialcharsbx($row[
'DETAIL_PAGE_URL']).$referer.
"</url>\n";
1902 $itemsContent .=
"<price>".$minPrice.
"</price>\n";
1903 if ($minPrice < $fullPrice)
1904 $itemsContent .=
"<oldprice>".$fullPrice.
"</oldprice>\n";
1905 $itemsContent .=
"<currencyId>".$minPriceCurrency.
"</currencyId>\n";
1907 $itemsContent .=
"<vat>".$vatList[$row[
'VAT_ID']].
"</vat>\n";
1909 $itemsContent .=
"<categoryId>".$row[
'CATEGORY_ID'].
"</categoryId>\n";
1911 if (!empty($row[
'PICTURE']))
1912 $itemsContent .=
"<picture>".$row[
'PICTURE'].
"</picture>\n";
1923 $itemsContent .=
"<name>".yandex_text2xml($row[
'NAME'],
$itemOptions).
"</name>\n";
1926 $itemsContent .=
"<description>".$row[
'DESCRIPTION'].
"</description>\n";
1933 $value = yandex_get_value(
1942 $itemsContent .=
$value.
"\n";
1945 unset($paramKey, $prop_id);
1961 $value = yandex_get_value(
1970 $itemsContent .=
$value.
"\n";
1992 $value = yandex_get_value(
2001 $itemsContent .=
$value.
"\n";
2007 $itemsContent .=
"</offer>\n";
2020 'SECTION_CHAINS' =>
true,
2021 'PROPERTIES' =>
true
2027 if ($itemsContent !==
'')
2029 unset($itemsContent);
2031 unset($simpleIdsList, $skuIdsList);
2032 unset(
$items, $itemIdsList);
2047 $finalExport =
true;
2052 if ($boolNeedRootSection)
2068 $content .=
"</offers>\n".
"</shop>\n".
"</yml_catalog>\n";
2102 Sale\DiscountCouponsManager::unFreezeCouponStorage();
2109 if (isset($USER_TMP))
const YANDEX_SKU_EXPORT_PROP
const YANDEX_SKU_EXPORT_ALL
const BX_CATALOG_FILENAME_REG
const YANDEX_SKU_EXPORT_MIN_PRICE
if($USER->IsAuthorized()) if(!function_exists("yandex_replace_special")) if(!function_exists("yandex_text2xml")) $usedProtocol
static preloadPriceData(array $productIds, array $catalogGroups)
const RESULT_MODE_COMPONENT
static setConfig(array $config)
static convertEncoding($data, $charsetFrom, $charsetTo)
static SetDiscountProductCache($arItem, $arParams=array())
static SetProductSectionsCache($arItemIDs)
static ClearDiscountCache($arTypes)
static SetProductPropertiesCache($intProductID, $arProps)
static GetOptimalPrice($intProductID, $quantity=1, $arUserGroups=array(), $renewal="N", $priceList=array(), $siteID=false, $arDiscountCoupons=false)
static ConvertCurrency($valSum, $curFrom, $curTo, $valDate="")
static GetNavChain($IBLOCK_ID, $SECTION_ID, $arSelect=array(), $arrayResult=false)
static GetVATDataByIDList(array $list)
static GetInfoByProductIBlock($intIBlockID)
static GetFileArray($fileId, $uploadDir=false)
static GetList($arOrder=array("SORT"=>"ASC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetList($arOrder=array("SORT"=>"ASC"), $arFilter=array(), $bIncCnt=false, $arSelect=array(), $arNavStartParams=false)
static isValidField(string $field)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
$_SERVER["DOCUMENT_ROOT"]
if(! $ar_profile) $strFile
if($ar_profile["DEFAULT_PROFILE"] !='Y') $firstStep
CheckSerializedData($str, $max_depth=200)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Rel2Abs($curdir, $relpath)
GetMessage($name, $aReplace=null)
TruncateText($strText, $intLen)
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."%"
if(!empty($arOffers['IBLOCK_ID'])) $arCondSelectProp
if(empty($arRunErrors)) $itemsFile
if(!CCatalog::IsUserExists()) $saleIncluded
if($vatExport) $itemOptions
$ar_iblock['DETAIL_PAGE_URL']
if(!empty($XML_DATA['PRICE'])) $priceTypeList
if(empty($arRunErrors)) $arUserTypeFormat
if( $fieldsExist) if($parametricFieldsExist) $commonFields
if(!empty( $arOffers[ 'IBLOCK_ID'])) if($boolOffers) $propertyIdList
if( $site[ 'SERVER_NAME']==='') if($site['SERVER_NAME']==='') $arProperties
if(empty($arRunErrors)) $selectedPriceType
if( $fieldsExist) if($parametricFieldsExist) $needProperties
yandex_text2xml($text, $bHSC=false, $bDblQuote=false)
if( $USER->IsAuthorized()) yandex_replace_special($arg)