From 1ad5ecf6a223a27469a666642d36c970fef9c640 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 18 Dec 2018 12:23:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B9=20=D0=B2=20ICML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../classes/general/icml/RetailCrmICML.php | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php index 98425ac4..5c04cc3d 100644 --- a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php +++ b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php @@ -111,6 +111,17 @@ class RetailCrmICML } + private function setSiteAddress($block_id) + { + $site = CAllIBlock::GetSite($block_id)->Fetch(); + + if ($site['SERVER_NAME']) { + $this->serverName = $site['SERVER_NAME']; + } else { + $this->serverName = $this->defaultServerName; + } + } + protected function PrepareSettings() { foreach ($this->propertiesSKU as $iblock => $arr) { @@ -118,6 +129,7 @@ class RetailCrmICML $this->propertiesSKU[$iblock][$id] = strtoupper($sku); } } + foreach ($this->propertiesProduct as $iblock => $arr) { foreach ($arr as $id => $prod) { $this->propertiesProduct[$iblock][$id] = strtoupper($prod); @@ -202,22 +214,27 @@ class RetailCrmICML { $categories = array(); foreach ($this->iblocks as $id) { + $this->setSiteAddress($id); $filter = array("IBLOCK_ID" => $id); $dbRes = CIBlockSection::GetList(array("left_margin" => "asc"), $filter); $hasCategories = false; + while ($arRes = $dbRes->Fetch()) { $categories[$arRes['ID']] = $arRes; + $categories[$arRes['ID']]['SITE'] = $this->protocol . $this->serverName; $hasCategories = true; } + if (!$hasCategories) { $iblock = CIBlock::GetByID($id)->Fetch(); - $arRes = Array(); + $arRes = array(); $arRes['ID'] = $this->mainSection + $id; $arRes['IBLOCK_SECTION_ID'] = 0; $arRes['NAME'] = sprintf(GetMessage('ROOT_CATEGORY_FOR_CATALOG'), $iblock['NAME']); $categories[$arRes['ID']] = $arRes; + $categories[$arRes['ID']]['SITE'] = $this->protocol . $this->serverName; } } @@ -226,15 +243,25 @@ class RetailCrmICML protected function BuildCategory($arCategory) { - return " - PrepareValue($arCategory["ID"]) . "\"" - . ( intval($arCategory["IBLOCK_SECTION_ID"] ) > 0 ? - " parentId=\"" . $this->PrepareValue($arCategory["IBLOCK_SECTION_ID"]) . "\"" - :"") - . ">" - . $this->PrepareValue($arCategory["NAME"]) - . "\n"; + $category = + "PrepareValue($arCategory["ID"]) . "\"" + . (intval($arCategory["IBLOCK_SECTION_ID"]) > 0 ? + " parentId=\"" . $this->PrepareValue($arCategory["IBLOCK_SECTION_ID"]) . "\"" + :"") + . ">\n\t" + . "" . $this->PrepareValue($arCategory["NAME"]) . "\n"; + if (CFile::GetPath($arCategory["DETAIL_PICTURE"])) { + $category .= "\t" . $arCategory['SITE'] . CFile::GetPath($arCategory["DETAIL_PICTURE"]) . "\n"; + } + + if (CFile::GetPath($arCategory["PICTURE"])) { + $category .= "\t" . $arCategory['SITE'] . CFile::GetPath($arCategory["PICTURE"]) . "\n"; + } + + $category .= "\n"; + + return $category; } protected function BuildOffers(&$allCategories) @@ -246,14 +273,7 @@ class RetailCrmICML ); foreach ($this->iblocks as $key => $id) { - $site = CAllIBlock::GetSite($id)->Fetch(); - - if ($site['SERVER_NAME']) { - $this->serverName = $site['SERVER_NAME']; - } else { - $this->serverName = $this->defaultServerName; - } - + $this->setSiteAddress($id); $barcodes = array(); $dbBarCode = CCatalogStoreBarCode::getList(