1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
froogle_run.php
См. документацию.
1<?php
2//<title>Froogle</title>
3IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/catalog/data_export.php');
4
5global $USER;
8{
9 $bTmpUserCreated = true;
10 if (isset($USER))
11 $USER_TMP = $USER;
12 $USER = new CUser();
13}
14
16
17function PrepareString($str, $KillTags = False)
18{
19 if ($KillTags)
20 {
21 $str = strip_tags($str);
22 }
23 $str = str_replace("\r", "", str_replace("\n", "", str_replace("\t", " ", $str)));
24 return $str;
25}
26
28
29if (CModule::IncludeModule("iblock") && CModule::IncludeModule("catalog"))
30{
31 $IBLOCK_ID = intval($IBLOCK_ID);
32 $db_iblock = CIBlock::GetByID($IBLOCK_ID);
33 if ($IBLOCK_ID <= 0 || (!($ar_iblock = $db_iblock->Fetch())))
34 {
35 $strExportErrorMessage .= "Information block #".$IBLOCK_ID." does not exist.\n";
36 }
37/* elseif (!CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, 'iblock_admin_display'))
38 {
39 $strCSVError .= str_replace('#IBLOCK_ID#',$IBLOCK_ID,GetMessage('CET_ERROR_IBLOCK_PERM')).'<br>';
40 } */
41
42 if ($strExportErrorMessage == '')
43 {
44 $bAllSections = False;
46 if (!empty($V) && is_array($V))
47 {
48 foreach ($V as $key => $value)
49 {
50 if (trim($value)=="0")
51 {
52 $bAllSections = True;
53 break;
54 }
55 if (intval($value)>0)
56 {
57 $arSections[] = intval($value);
58 }
59 }
60 }
61
62 if (!$bAllSections && empty($arSections))
63 $strExportErrorMessage .= "Section list is not set.\n";
64 }
65
66 if ($strExportErrorMessage == '')
67 {
68 $arFilter = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", 'CHECK_PERMISSIONS' => 'N');
69 if (!$bAllSections)
70 {
71 $arFilter["INCLUDE_SUBSECTIONS"] = "Y";
72 $arFilter["SECTION_ID"] = $arSections;
73 }
74
75 $arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "LANG_DIR", "DETAIL_PAGE_URL", "EXTERNAL_ID");
77 $arPTypes = array();
78 while ($ar_res = $db_res->Fetch())
79 {
80 if (!in_array($ar_res["CATALOG_GROUP_ID"], $arPTypes))
81 {
82 $arPTypes[] = $ar_res["CATALOG_GROUP_ID"];
83 $arSelect[] = "CATALOG_GROUP_".$ar_res["CATALOG_GROUP_ID"];
84 }
85 }
86
87 $arSectionPaths = array();
88 }
89
90 if ($SETUP_FILE_NAME == '')
91 {
92 $strExportErrorMessage .= GetMessage("CATI_NO_SAVE_FILE")."<br>";
93 }
95 {
96 $strExportErrorMessage .= GetMessage("CES_ERROR_BAD_EXPORT_FILENAME")."<br>";
97 }
98
99 if ($strExportErrorMessage == '')
100 {
102 if (mb_strtolower(mb_substr($SETUP_FILE_NAME, mb_strlen($SETUP_FILE_NAME) - 4)) != ".txt")
103 $SETUP_FILE_NAME .= ".txt";
104/* if ($GLOBALS["APPLICATION"]->GetFileAccessPermission($SETUP_FILE_NAME) < "W")
105 $strExportErrorMessage .= str_replace("#FILE#", $SETUP_FILE_NAME, "You do not have access rights to add or modify #FILE#")."<br>"; */
106 }
107
108 if ($strExportErrorMessage == '')
109 {
110 if (!$fp = @fopen($_SERVER["DOCUMENT_ROOT"].$SETUP_FILE_NAME, "wb"))
111 {
112 $strExportErrorMessage .= "Can not open \"".$_SERVER["DOCUMENT_ROOT"].$SETUP_FILE_NAME."\" file for writing.\n";
113 }
114 else
115 {
116 if (!@fwrite($fp, "product_url name description image_url category price\n"))
117 {
118 $strExportErrorMessage .= "Can not write in \"".$_SERVER["DOCUMENT_ROOT"].$SETUP_FILE_NAME."\" file.\n";
119 @fclose($fp);
120 }
121 }
122 }
123
124 if ($strExportErrorMessage == '')
125 {
126 if (!($ar_usd_cur = CCurrency::GetByID("USD")))
127 {
128 $strExportErrorMessage .= "USD currency is not found.\n";
129 }
130 }
131
132 if ($strExportErrorMessage == '')
133 {
134 $db_elems = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
135 while ($ar_elems = $db_elems->GetNext())
136 {
137 $ar_file = CFile::GetFileArray($ar_elems["DETAIL_PICTURE"]);
138 if (!$ar_file)
139 $ar_file = CFile::GetFileArray($ar_elems["PREVIEW_PICTURE"]);
140
141 if ($ar_file)
142 {
143 if(mb_substr($ar_file["SRC"], 0, 1) == "/")
144 $strImage = "http://".COption::GetOptionString("main", "server_name", $SERVER_NAME).$ar_file["SRC"];
145 else
146 $strImage = $ar_file["SRC"];
147 }
148 else
149 {
150 $strImage = "";
151 }
152
153 if (!is_set($arSectionPaths, intval($ar_elems["IBLOCK_SECTION_ID"])))
154 {
155 $strCategory = $ar_iblock["NAME"];
156 $sections_path = GetIBlockSectionPath($IBLOCK_ID, $ar_elems["IBLOCK_SECTION_ID"]);
157 while ($arSection = $sections_path->GetNext())
158 {
159 if ($strCategory <> '') $strCategory .= ">";
160 $strCategory .= $arSection["NAME"];
161 }
162 $arSectionPaths[intval($ar_elems["IBLOCK_SECTION_ID"])] = PrepareString($strCategory);
163 }
164
165 $minPrice = 0;
166 for ($i = 0, $intPCount = count($arPTypes); $i < $intPCount; $i++)
167 {
168 if ($ar_elems["CATALOG_CURRENCY_".$arPTypes[$i]] == '') continue;
169 $tmpPrice = Round(CCurrencyRates::ConvertCurrency($ar_elems["CATALOG_PRICE_".$arPTypes[$i]], $ar_elems["CATALOG_CURRENCY_".$arPTypes[$i]], "USD"), 2);
170 if ($minPrice<=0 || $minPrice>$tmpPrice)
171 {
172 $minPrice = $tmpPrice;
173 }
174 }
175
176 if ($minPrice <= 0) continue;
177
178 @fwrite($fp, "http://".
179 COption::GetOptionString("main", "server_name", $SERVER_NAME).
180 str_replace("//", "/", $ar_elems["DETAIL_PAGE_URL"]).
181 " ".
182 $ar_elems["~NAME"].
183 " ".
184 PrepareString($ar_elems["~PREVIEW_TEXT"], true).
185 " ".
186 $strImage.
187 " ".
188 $arSectionPaths[intval($ar_elems["IBLOCK_SECTION_ID"])].
189 " ".
190 $minPrice."\n");
191 }
192 @fclose($fp);
193 }
194}
195
197
199{
200 if (isset($USER_TMP))
201 {
202 $USER = $USER_TMP;
203 unset($USER_TMP);
204 }
205}
$db_res
Определения options_user_settings.php:8
$ar_res
Определения options_user_settings_set.php:16
const BX_CATALOG_FILENAME_REG
Определения include.php:51
static Disable()
Определения discount_save.php:38
static Enable()
Определения discount_save.php:33
static IsUserExists()
Определения catalog.php:1812
static GetByID($currency)
Определения currency.php:453
static ConvertCurrency($valSum, $curFrom, $curTo, $valDate="")
Определения currency_rate.php:393
static GetGroupsList($arFilter=array())
Определения cataloggroup.php:461
$str
Определения commerceml2.php:63
else $SETUP_FILE_NAME
Определения ebay_mip_run.php:56
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
PrepareString($str, $KillTags=False)
Определения froogle_run.php:17
GetIBlockSectionPath($IBLOCK_ID, $SECTION_ID)
Определения iblock.php:520
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$IBLOCK_ID
Определения csv_new_run.php:168
global $USER
Определения csv_new_run.php:40
$strExportErrorMessage
Определения csv_new_run.php:128
$bTmpUserCreated
Определения csv_new_run.php:41
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
Rel2Abs($curdir, $relpath)
Определения tools.php:3297
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
</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."%"
Определения waybill.php:936
$arFilter
Определения user_search.php:106
$arSections
Определения yandex_run.php:805
$db_iblock
Определения yandex_run.php:572
$ar_iblock['DETAIL_PAGE_URL']
Определения yandex_run.php:600
$bAllSections
Определения yandex_run.php:804