diff --git a/intaro.intarocrm/classes/general/ICMLLoader.php b/intaro.intarocrm/classes/general/ICMLLoader.php
index 18715118..b28e36ce 100644
--- a/intaro.intarocrm/classes/general/ICMLLoader.php
+++ b/intaro.intarocrm/classes/general/ICMLLoader.php
@@ -1,33 +1,36 @@
iblocks) < count($this->articleProperties))
return false;
-
+
$this->PrepareFile();
$this->PreWriteCatalog();
-
+
$categories = $this->GetCategories();
-
+
$this->WriteCategories($categories);
-
+
$this->PreWriteOffers();
$this->BuildOffers($categories);
$this->PostWriteOffers();
@@ -36,9 +39,9 @@ class ICMLLoader {
$this->CloseFile();
return true;
-
+
}
-
+
protected function PrepareValue($text)
{
$newText = $this->application->ConvertCharset($text, LANG_CHARSET, $this->encoding);
@@ -46,7 +49,7 @@ class ICMLLoader {
$newText = str_replace("&", "&", $newText);
return $newText;
}
-
+
protected function PrepareFile()
{
$fullFilename = $_SERVER["DOCUMENT_ROOT"] . $this->filename;
@@ -57,7 +60,7 @@ class ICMLLoader {
else
return true;
}
-
+
protected function PreWriteCatalog()
{
@fwrite($this->fp, "PrepareValue(Date("Y-m-d H:i:s")) . "\">\n");
@@ -68,7 +71,7 @@ class ICMLLoader {
@fwrite($this->fp, "".$this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n");
}
-
+
protected function WriteCategories($categories)
{
$stringCategories = "";
@@ -83,33 +86,33 @@ class ICMLLoader {
{
@fwrite($this->fp, "\n");
}
-
+
protected function PostWriteOffers()
{
@fwrite($this->fp, "\n");
}
-
+
protected function WriteOffers($offers)
{
@fwrite($this->fp, $offers);
}
-
+
protected function PostWriteCatalog()
{
@fwrite($this->fp, "\n");
@fwrite($this->fp, "\n");
}
-
+
protected function CloseFile()
{
@fclose($this->fp);
}
-
-
+
+
protected function GetCategories()
{
$categories = array();
- foreach ($this->iblocks as $id)
+ foreach ($this->iblocks as $id)
{
$filter = Array(
"IBLOCK_ID" => $id,
@@ -128,18 +131,18 @@ class ICMLLoader {
if (!$hasCategories)
{
$iblock = CIBlock::GetByID($id)->Fetch();
-
+
$arRes = Array();
$arRes['ID'] = $this->mainSection + $id;
$arRes['IBLOCK_SECTION_ID'] = 0;
- $arRes['NAME'] = "Основной раздел каталога " . $iblock['NAME'];
+ $arRes['NAME'] = sprintf(GetMessage('ROOT_CATEGORY_FOR_CATALOG'), $iblock['NAME']);
$categories[$arRes['ID']] = $arRes;
}
}
return $categories;
}
-
+
protected function BuildCategory($arCategory)
{
return "
@@ -150,12 +153,12 @@ class ICMLLoader {
. ">"
. $this->PrepareValue($arCategory["NAME"])
. "\n";
-
+
}
-
+
protected function BuildOffers(&$allCategories)
{
- foreach ($this->iblocks as $key => $id)
+ foreach ($this->iblocks as $key => $id)
{
$iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch();
@@ -177,10 +180,10 @@ class ICMLLoader {
"LANG_DIR",
"DETAIL_PAGE_URL"
);
-
+
if (isset($this->articleProperties[$id]))
$arSelect[] = "PROPERTY_" . $this->articleProperties[$id];
-
+
$filter = Array (
"IBLOCK_ID" => $id,
@@ -192,7 +195,7 @@ class ICMLLoader {
$dbResProducts = CIBlockElement::GetList(array(), $filter, false, false, $arSelect);
$stringOffers = "";
while ($product = $dbResProducts->GetNextElement()) {
-
+
$product = $product->GetFields();
// Get categories in InfoBlock
@@ -205,16 +208,16 @@ class ICMLLoader {
);
}
if (count($categories) == 0) {
-
+
$catId = $this->mainSection + $id;
$categories[$catId] = $allCategories[$catId];
}
-
+
$existOffer = false;
if (!empty($iblockOffer['IBLOCK_ID'])) {
-
-
+
+
$arFilterOffer = Array (
'IBLOCK_ID' => $iblockOffer['IBLOCK_ID'],
'PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'] => $product["ID"]
@@ -252,7 +255,7 @@ class ICMLLoader {
}
}
if (!$existOffer) {
-
+
$offer = CCatalogProduct::GetByID($product['ID']);
$product['QUANTITY'] = $offer["QUANTITY"];
@@ -266,15 +269,15 @@ class ICMLLoader {
$stringOffers .= $this->BuildOffer($product, $categories, $iblock);
}
-
+
$count++;
if ($count == 1000) {
$this->WriteOffers($stringOffers);
$stringOffers = "";
}
-
+
}
-
+
if ($stringOffers != "") {
$this->WriteOffers($stringOffers);
$stringOffers = "";
@@ -282,15 +285,15 @@ class ICMLLoader {
}
}
-
-
+
+
protected function BuildOffer($arOffer, $categories, $iblock)
{
$offer = "";
$offer .= "PrepareValue($arOffer["ID"]) . "\" ".
"productId=\"" . $this->PrepareValue($arOffer["PRODUCT_ID"]) . "\" ".
"quantity=\"" . $this->PrepareValue(DoubleVal($arOffer['QUANTITY'])) . "\">\n";
-
+
$offer .= "http://" . $this->PrepareValue($iblock['IBLOCK_DB']['SERVER_NAME']) . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "\n";
$offer .= "" . $this->PrepareValue($arOffer['PRICE']) . "\n";
@@ -329,5 +332,5 @@ class ICMLLoader {
$offer.= "\n";
return $offer;
}
-
+
}
\ No newline at end of file
diff --git a/intaro.intarocrm/lang/ru/classes/general/ICMLLoader.php b/intaro.intarocrm/lang/ru/classes/general/ICMLLoader.php
new file mode 100644
index 00000000..e21acd04
--- /dev/null
+++ b/intaro.intarocrm/lang/ru/classes/general/ICMLLoader.php
@@ -0,0 +1,2 @@
+