From 596709946c2444648329beb29f735880a50867e0 Mon Sep 17 00:00:00 2001 From: "m.korolev" Date: Fri, 13 Sep 2013 16:15:54 +0400 Subject: [PATCH 1/5] Extended properties add to export --- .../classes/general/ICMLLoader.php | 107 +++-- intaro.intarocrm/export/export_run.php | 4 +- intaro.intarocrm/export/export_setup.php | 421 ++++++++++++------ intaro.intarocrm/install/index.php | 73 +-- intaro.intarocrm/install/step5.php | 323 +++++++++----- 5 files changed, 619 insertions(+), 309 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICMLLoader.php b/intaro.intarocrm/classes/general/ICMLLoader.php index 18715118..080c8b89 100644 --- a/intaro.intarocrm/classes/general/ICMLLoader.php +++ b/intaro.intarocrm/classes/general/ICMLLoader.php @@ -4,12 +4,13 @@ class ICMLLoader { public $iblocks; public $filename; - public $articleProperties; + public $propertiesSKU; + public $propertiesProduct; public $application; public $encoding = 'utf-8'; protected $fp; - protected $mainSection = 1000000; + protected $mainSection = 1000000; public function Load() { @@ -20,6 +21,8 @@ class ICMLLoader { if (count($this->iblocks) < count($this->articleProperties)) return false; + $this->PrepareSettings(); + $this->PrepareFile(); $this->PreWriteCatalog(); @@ -39,6 +42,20 @@ class ICMLLoader { } + protected function PrepareSettings() + { + foreach ($this->propertiesSKU as $iblock => $arr) { + foreach ($arr as $id => $sku) { + $this->propertiesSKU[$iblock][$id] = strtoupper($sku); + } + } + foreach ($this->propertiesProduct as $iblock => $arr) { + foreach ($arr as $id => $prod) { + $this->propertiesProduct[$iblock][$id] = strtoupper($prod); + } + } + } + protected function PrepareValue($text) { $newText = $this->application->ConvertCharset($text, LANG_CHARSET, $this->encoding); @@ -60,12 +77,11 @@ class ICMLLoader { protected function PreWriteCatalog() { - @fwrite($this->fp, "PrepareValue(Date("Y-m-d H:i:s")) . "\">\n"); - @fwrite($this->fp, "\n"); - - @fwrite($this->fp, "". $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n"); - - @fwrite($this->fp, "".$this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n"); + @fwrite($this->fp, "PrepareValue(Date("Y-m-d H:i:s")) . "\">\n + \n + " . $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n + " . $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n" + ); } @@ -96,8 +112,8 @@ class ICMLLoader { protected function PostWriteCatalog() { - @fwrite($this->fp, "\n"); - @fwrite($this->fp, "\n"); + @fwrite($this->fp, "\n + \n"); } protected function CloseFile() @@ -157,11 +173,9 @@ class ICMLLoader { { foreach ($this->iblocks as $key => $id) { - $iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch(); $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id); - $arSelect = Array ( "ID", "LID", @@ -178,8 +192,10 @@ class ICMLLoader { "DETAIL_PAGE_URL" ); - if (isset($this->articleProperties[$id])) - $arSelect[] = "PROPERTY_" . $this->articleProperties[$id]; + foreach ($this->propertiesProduct[$id] as $key => $propProduct) { + if ($this->propertiesProduct[$id][$key] != "") + $arSelect[] = "PROPERTY_" . $propProduct; + } $filter = Array ( @@ -195,7 +211,23 @@ class ICMLLoader { $product = $product->GetFields(); - // Get categories in InfoBlock + // Get properties of product + $resPropertiesProduct = Array(); + foreach ($this->propertiesProduct[$id] as $key => $propProduct) { + $resPropertiesProduct[$key] = ""; + if ($propProduct != "") { + $propDesc = CIBlockProperty::GetByID($propProduct, $id)->GetNext(); + + if ($propDesc['PROPERTY_TYPE'] == 'E') { + $el = CIBlockElement::GetById($product["PROPERTY_" . $propProduct . "_VALUE"])->Fetch(); + $resPropertiesProduct[$key] = $el['NAME']; + } else { + $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"]; + } + } + } + + // Get categories of product $categories = Array(); $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true); while ($arResCategory = $dbResCategories->Fetch()) { @@ -214,7 +246,6 @@ class ICMLLoader { $existOffer = false; if (!empty($iblockOffer['IBLOCK_ID'])) { - $arFilterOffer = Array ( 'IBLOCK_ID' => $iblockOffer['IBLOCK_ID'], 'PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'] => $product["ID"] @@ -226,9 +257,11 @@ class ICMLLoader { "DETAIL_PAGE_URL", "DETAIL_PICTURE" ); - if (isset($this->articleProperties[$id])) - $arSelectOffer[] = "PROPERTY_" . $this->articleProperties[$id]; - + + foreach ($this->propertiesSKU[$id] as $key => $propSKU) { + if ($this->propertiesSKU[$id][$key] != "") + $arSelectOffer[] = "PROPERTY_" . $propSKU; + } $rsOffers = CIBlockElement::GetList(array(), $arFilterOffer, false, false, $arSelectOffer); while ($arOffer = $rsOffers->GetNext()) { @@ -241,9 +274,27 @@ class ICMLLoader { $arOffer['DETAIL_PICTURE'] = $product["DETAIL_PICTURE"]; $arOffer['PREVIEW_PICTURE'] = $product["PREVIEW_PICTURE"]; $arOffer['PRODUCT_NAME'] = $product["NAME"]; - if (isset($this->articleProperties[$id])) - $arOffer['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"]; + + // Get properties of offer + + foreach ($this->propertiesSKU[$id] as $key => $propSKU) { + if ($propSKU != "") { + $propDesc = CIBlockProperty::GetByID($propSKU,$arOffer['ID'])->GetNext(); + if ($propDesc['PROPERTY_TYPE'] == 'E') { + $el = CIBlockElement::GetById($product["PROPERTY_" . $propSKU . "_VALUE"])->Fetch(); + $arOffer[$key] = $el['NAME']; + } else { + $arOffer[$key] = $arOffer["PROPERTY_" . $propSKU . "_VALUE"]; + } + } + } + + foreach ($resPropertiesProduct as $key => $propProduct) { + if ($this->propertiesProduct[$id][$key] != "") + $arOffer[$key] = $propProduct; + } + $dbPrice = GetCatalogProductPrice($arOffer["ID"],1); $arOffer['PRICE'] = $dbPrice['PRICE']; @@ -258,8 +309,11 @@ class ICMLLoader { $product['PRODUCT_ID'] = $product["ID"]; $product['PRODUCT_NAME'] = $product["NAME"]; - if (isset($this->articleProperties[$id])) - $product['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"]; + + foreach ($resPropertiesProduct as $key => $propProduct) { + if ($this->propertiesProduct[$id][$key] != "") + $product[$key] = $propProduct; + } $dbPrice = GetCatalogProductPrice($product["ID"],1); $product['PRICE'] = $dbPrice['PRICE']; @@ -323,9 +377,12 @@ class ICMLLoader { $offer .= "" . $this->PrepareValue($arOffer["EXTERNAL_ID"]) . "\n"; $offer .= "" . $this->PrepareValue($arOffer["PRODUCT_NAME"]) . "\n"; - if (isset($arOffer["ARTICLE"])) - $offer .= "
" . $this->PrepareValue($arOffer["ARTICLE"]) . "
\n"; + foreach ($this->propertiesProduct[$iblock['IBLOCK_DB']['ID']] as $key => $propProduct) { + if ($propProduct != "" && $arOffer[$key] != null) + $offer .= "<" . $key . ">" . $this->PrepareValue($arOffer[$key]) . "\n"; + } + $offer.= "\n"; return $offer; } diff --git a/intaro.intarocrm/export/export_run.php b/intaro.intarocrm/export/export_run.php index ea2d7464..b0ddb912 100644 --- a/intaro.intarocrm/export/export_run.php +++ b/intaro.intarocrm/export/export_run.php @@ -2,7 +2,6 @@ set_time_limit(0); - global $APPLICATION; if (!CModule::IncludeModule("iblock")) return; @@ -13,7 +12,8 @@ if (!CModule::IncludeModule("intaro.intarocrm")) $loader = new ICMLLoader(); $loader->iblocks = $IBLOCK_EXPORT; -$loader->articleProperties = $IBLOCK_PROPERTY_ARTICLE; +$loader->propertiesSKU = $IBLOCK_PROPERTY_SKU; +$loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT; $loader->filename = $SETUP_FILE_NAME; $loader->application = $APPLICATION; $loader->Load(); \ No newline at end of file diff --git a/intaro.intarocrm/export/export_setup.php b/intaro.intarocrm/export/export_setup.php index 1fafdeee..e7da7e4c 100644 --- a/intaro.intarocrm/export/export_setup.php +++ b/intaro.intarocrm/export/export_setup.php @@ -1,30 +1,29 @@ - 1) { - - if (count($IBLOCK_EXPORT) < count($IBLOCK_PROPERTY_ARTICLE)) - $arSetupErrors[] = GetMessage("ERROR_ARTICLE_NOT_SET"); - if (strlen($SETUP_FILE_NAME)<=0) { $arSetupErrors[] = GetMessage("CET_ERROR_NO_FILENAME"); @@ -54,18 +53,43 @@ if ($STEP==1) ?> + + +
+ +

Настройки инфоблоков



"Артикул", + "manufacturer" => "Производитель", + "color" => "Цвет", + "weight" => "Вес", + "size" => "Размер", + ); + + $iblockPropertiesHint = Array( + "article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"), + "manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"), + "color" => Array("COLOR", "CVET"), + "weight" => Array("WEIGHT", "VES", "VEC"), + "size" => Array("SIZE", "RAZMER"), + ); $boolAll = false; @@ -73,42 +97,70 @@ if ($STEP==1) $intCountAvailIBlock = 0; $arIBlockList = array(); $db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W')); - while ($res = $db_res->Fetch()) + while ($iblock = $db_res->Fetch()) { - if ($arCatalog = CCatalog::GetByIDExt($res["ID"])) + if ($arCatalog = CCatalog::GetByIDExt($iblock["ID"])) { if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") { - $arSiteList = array(); - $rsSites = CIBlock::GetSite($res["ID"]); - while ($arSite = $rsSites->Fetch()) - { - $arSiteList[] = $arSite["SITE_ID"]; - } - $db_properties = CIBlock::GetProperties($res['ID'], Array()); - - $properties = Array(); + $propertiesSKU = null; + if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") + { + $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]); + + $db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array()); while($prop = $db_properties->Fetch()) - $properties[] = $prop; + $propertiesSKU[] = $prop; + + $oldPropertySKU = null; + if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key]; + } + } + } + + + $propertiesProduct = null; + $db_properties = CIBlock::GetProperties($iblock['ID'], Array()); + while($prop = $db_properties->Fetch()) + $propertiesProduct[] = $prop; + + $oldPropertyProduct = null; + if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key]; + } + } + + $arSiteList = array(); + $rsSites = CIBlock::GetSite($iblock["ID"]); + while ($arSite = $rsSites->Fetch()) + { + $arSiteList[] = $arSite["SITE_ID"]; + } - if (count($IBLOCK_EXPORT) != 0) - $boolExport = (in_array($res['ID'], $IBLOCK_EXPORT)); - else - $boolExport = true; + if (count($IBLOCK_EXPORT) != 0) + $boolExport = (in_array($iblock['ID'], $IBLOCK_EXPORT)); + else + $boolExport = true; + - $arIBlockList[] = array( - 'ID' => $res['ID'], - 'NAME' => $res['NAME'], - 'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'], - 'IBLOCK_EXPORT' => $boolExport, - 'PROPERTIES' => $properties, - 'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null, - 'SITE_LIST' => '('.implode(' ',$arSiteList).')', - ); + $arIBlockList[] = array( + 'ID' => $iblock['ID'], + 'NAME' => $iblock['NAME'], + 'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'], + 'IBLOCK_EXPORT' => $boolExport, + 'PROPERTIES_SKU' => $propertiesSKU, + 'PROPERTIES_PRODUCT' => $propertiesProduct, + 'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU, + 'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct, + 'SITE_LIST' => '('.implode(' ',$arSiteList).')', + ); - if ($boolExport) - $intCountChecked++; - $intCountAvailIBlock++; + if ($boolExport) + $intCountChecked++; + $intCountAvailIBlock++; } } } @@ -120,105 +172,148 @@ if ($STEP==1) $boolAll = true; } + + ?> - - - - - - + + + + + + +
-
+ Выбрать все инфоблоки + > +
+
+
+ + $arIBlock):?> +
+
+ + ]" + id="IBLOCK_EXPORT" + value="" + + onclick="checkOne(this,);" + > +
+
+
+ > + + + + + + + + + + + $property): ?> + + + - - - - - - - - - $arIBlock) - { - ?> - - - - - - - -
+
Выгружаемое свойство
-
-   -
+
Свойство товара
+
+
Свойство торгового предложения
+
+ -
-
- - - > - - -   -
- - - - ]" - id="IBLOCK_EXPORT" - value="" - - onclick="checkOne(this,);" - > - - - " + name="IBLOCK_PROPERTY_PRODUCT[][]" + class="property-export" + onchange="propertyChange(this);"> + + - - -
+ + +
+ +
+
+
+ + + + + + +
-
-
+

Настройки экспорта

+

function checkAll(obj,cnt) { - var boolCheck = obj.checked; - for (i = 0; i < cnt; i++) - { - BX('IBLOCK_EXPORT'+i).checked = boolCheck; - } - BX('count_checked').value = (boolCheck ? cnt : 0); + for (i = 0; i < cnt; i++) + { + if (obj.checked) + BX.removeClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); + } + var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE')); + if (obj.checked) + BX.removeClass(table,"iblock-export-table-display-none"); + var easing = new BX.easing({ + duration : 150, + start : {opacity : obj.checked ? 0 : 100 }, + finish : {opacity: obj.checked ? 100 : 0 }, + transition : BX.easing.transitions.linear, + step : function(state){ + for (i = 0; i < cnt; i++) + { + BX('IBLOCK_EXPORT_TABLE'+(i+1)).style.opacity = state.opacity/100; + } + }, + complete : function() { + for (i = 0; i < cnt; i++) + { + if (!obj.checked) + BX.addClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); + } + } + }); + easing.animate(); + var boolCheck = obj.checked; + for (i = 0; i < cnt; i++) + { + BX('IBLOCK_EXPORT'+(i+1)).checked = boolCheck; + } + BX('count_checked').value = (boolCheck ? cnt : 0); }; function checkOne(obj,cnt) { - var boolCheck = obj.checked; - var intCurrent = parseInt(BX('count_checked').value); - intCurrent += (boolCheck ? 1 : -1); - BX('icml_export_all').checked = (intCurrent < cnt ? false : true); - BX('count_checked').value = intCurrent; - if (!boolCheck) - BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_PROPERTY_ARTICLE')).value = 'none'; + var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE')); + if (obj.checked) + BX.removeClass(table,"iblock-export-table-display-none"); + var easing = new BX.easing({ + duration : 150, + start : {opacity : obj.checked ? 0 : 100 }, + finish : {opacity: obj.checked ? 100 : 0 }, + transition : BX.easing.transitions.linear, + step : function(state){ + table.style.opacity = state.opacity/100; + }, + complete : function() { + if (!obj.checked) + BX.addClass(table,"iblock-export-table-display-none"); + } + }); + easing.animate(); + var boolCheck = obj.checked; + var intCurrent = parseInt(BX('count_checked').value); + intCurrent += (boolCheck ? 1 : -1); + BX('icml_export_all').checked = (intCurrent < cnt ? false : true); + BX('count_checked').value = intCurrent; + }; + function propertyChange(obj) + { + if (BX(obj.id).value !== 'none') { + if (obj.id.indexOf("SKU") !== -1) + BX(obj.id.replace('SKU','PRODUCT')).value = 'none'; + else + BX(obj.id.replace('PRODUCT','SKU')).value = 'none'; + } }; @@ -279,7 +426,7 @@ if ($STEP==1) "> - + "> diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index c5bf34b3..a0ebc8d7 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -828,21 +828,22 @@ class intaro_intarocrm extends CModule { $arResult['errCode'] = 'ERR_FIELDS_IBLOCK'; else $iblocks = $_POST['IBLOCK_EXPORT']; - - if (!isset($_POST['IBLOCK_PROPERTY_ARTICLE'])) - $arResult['errCode'] = 'ERR_FIELDS_ARTICLE'; + + if(!isset($_POST['IBLOCK_PROPERTY_SKU'])) + $arResult['errCode'] = 'ERR_FIELDS_SKU'; else - $articleProperties = $_POST['IBLOCK_PROPERTY_ARTICLE']; + $propertiesSKU = $_POST['IBLOCK_PROPERTY_SKU']; + + if(!isset($_POST['IBLOCK_PROPERTY_PRODUCT'])) + $arResult['errCode'] = 'ERR_FIELDS_PRODUCT'; + else + $propertiesProduct = $_POST['IBLOCK_PROPERTY_PRODUCT']; if (!isset($_POST['SETUP_FILE_NAME'])) $arResult['errCode'] = 'ERR_FIELDS_FILE'; else $filename = $_POST['SETUP_FILE_NAME']; - - if (count($iblocks) < count($articleProperties)) - $arResult['errCode'] = 'ERR_ARTICLE_IBLOCK'; - - + if (!isset($_POST['TYPE_LOADING'])) $typeLoading = 0; else @@ -863,15 +864,16 @@ class intaro_intarocrm extends CModule { $arOldValues = Array( 'IBLOCK_EXPORT' => $iblocks, - 'IBLOCK_PROPERTY_ARTICLE' => $articleProperties, + 'IBLOCK_PROPERTY_SKU' => $propertiesSKU, + 'IBLOCK_PROPERTY_PRODUCT' => $propertiesProduct, 'SETUP_FILE_NAME' => $filename, 'SETUP_PROFILE_NAME' => $profileName ); global $oldValues; $oldValues = $arOldValues; $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php' ); return; } @@ -883,12 +885,14 @@ class intaro_intarocrm extends CModule { $loader = new ICMLLoader(); $loader->iblocks = $iblocks; - $loader->articleProperties = $articleProperties; + $loader->propertiesProduct = $propertiesProduct; + $loader->propertiesSKU = $propertiesSKU; $loader->filename = $filename; $loader->application = $APPLICATION; $loader->Load(); - } - + + } + if ($typeLoading == 'agent' || $typeLoading == 'cron') { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) { $dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT)); @@ -900,18 +904,18 @@ class intaro_intarocrm extends CModule { } } } - $ar = $this->GetProfileSetupVars($iblocks, $articleProperties, $filename); + $ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename); $PROFILE_ID = CCatalogExport::Add(array( - "LAST_USE" => false, - "FILE_NAME" => $this->INTARO_CRM_EXPORT, - "NAME" => $profileName, - "DEFAULT_PROFILE" => "N", - "IN_MENU" => "N", - "IN_AGENT" => "N", - "IN_CRON" => "N", - "NEED_EDIT" => "N", - "SETUP_VARS" => $ar - )); + "LAST_USE" => false, + "FILE_NAME" => $this->INTARO_CRM_EXPORT, + "NAME" => $profileName, + "DEFAULT_PROFILE" => "N", + "IN_MENU" => "N", + "IN_AGENT" => "N", + "IN_CRON" => "N", + "NEED_EDIT" => "N", + "SETUP_VARS" => $ar + )); if (intval($PROFILE_ID) <= 0) { $arResult['errCode'] = 'ERR_IBLOCK'; return; @@ -1075,21 +1079,26 @@ class intaro_intarocrm extends CModule { unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php'); } - function GetProfileSetupVars($iblocks, $articleProperties, $filename) { + function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename) { // Get string like IBLOCK_EXPORT[0]=3& // IBLOCK_EXPORT[1]=6& // IBLOCK_PROPERTY_ARTICLE[0]=ARTICLE& // IBLOCK_PROPERTY_ARTICLE[1]=ARTNUMBER& // SETUP_FILE_NAME=%2Fbitrix%2Fcatalog_export%2Ftestintarocrm.xml + //$arProfileFields = explode(",", $SETUP_FIELDS_LIST); $strVars = ""; - foreach ($iblocks as $key => $val) + foreach ($iblocks as $key => $val) $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; - foreach ($articleProperties as $key => $val) - $strVars .= 'IBLOCK_PROPERTY_ARTICLE[' . $key . ']=' . $val . '&'; - + foreach ($propertiesSKU as $iblock => $arr) + foreach ($arr as $id => $val) + $strVars .= 'IBLOCK_PROPERTY_SKU[' . $iblock . '][' . $id . ']=' . $val . '&'; + foreach ($propertiesProduct as $iblock => $arr) + foreach ($arr as $id => $val) + $strVars .= 'IBLOCK_PROPERTY_PRODUCT[' . $iblock . '][' . $id . ']=' . $val . '&'; + $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); - + return $strVars; } diff --git a/intaro.intarocrm/install/step5.php b/intaro.intarocrm/install/step5.php index 4b19cc2c..6cf45615 100644 --- a/intaro.intarocrm/install/step5.php +++ b/intaro.intarocrm/install/step5.php @@ -11,60 +11,115 @@ if(isset($arResult['errCode']) && $arResult['errCode']) global $oldValues; if (!empty($oldValues)) { $IBLOCK_EXPORT = $oldValues['IBLOCK_EXPORT']; - $IBLOCK_PROPERTY_ARTICLE = $oldValues['IBLOCK_PROPERTY_ARTICLE']; + $IBLOCK_PROPERTY_SKU = $oldValues['IBLOCK_PROPERTY_SKU']; + $IBLOCK_PROPERTY_PRODUCT = $oldValues['IBLOCK_PROPERTY_PRODUCT']; $SETUP_FILE_NAME = $oldValues['SETUP_FILE_NAME']; $SETUP_PROFILE_NAME = $oldValues['SETUP_PROFILE_NAME']; } ?> - + + + + + +

Настройки инфоблоков



"Артикул", + "manufacturer" => "Производитель", + "color" => "Цвет", + "weight" => "Вес", + "size" => "Размер", + ); + + $iblockPropertiesHint = Array( + "article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"), + "manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"), + "color" => Array("COLOR", "CVET"), + "weight" => Array("WEIGHT", "VES", "VEC"), + "size" => Array("SIZE", "RAZMER"), + ); + $boolAll = false; $intCountChecked = 0; $intCountAvailIBlock = 0; $arIBlockList = array(); $db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W')); - while ($res = $db_res->Fetch()) + while ($iblock = $db_res->Fetch()) { - if ($arCatalog = CCatalog::GetByIDExt($res["ID"])) + if ($arCatalog = CCatalog::GetByIDExt($iblock["ID"])) { if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") { - $arSiteList = array(); - $rsSites = CIBlock::GetSite($res["ID"]); - while ($arSite = $rsSites->Fetch()) - { - $arSiteList[] = $arSite["SITE_ID"]; - } - $db_properties = CIBlock::GetProperties($res['ID'], Array()); - - $properties = Array(); + $propertiesSKU = null; + if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") + { + $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]); + + $db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array()); while($prop = $db_properties->Fetch()) - $properties[] = $prop; + $propertiesSKU[] = $prop; + + $oldPropertySKU = null; + if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key]; + } + } + } + + + $propertiesProduct = null; + $db_properties = CIBlock::GetProperties($iblock['ID'], Array()); + while($prop = $db_properties->Fetch()) + $propertiesProduct[] = $prop; + + $oldPropertyProduct = null; + if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key]; + } + } + + $arSiteList = array(); + $rsSites = CIBlock::GetSite($iblock["ID"]); + while ($arSite = $rsSites->Fetch()) + { + $arSiteList[] = $arSite["SITE_ID"]; + } - if (count($IBLOCK_EXPORT) != 0) - $boolExport = (in_array($res['ID'], $IBLOCK_EXPORT)); - else - $boolExport = true; + if (count($IBLOCK_EXPORT) != 0) + $boolExport = (in_array($iblock['ID'], $IBLOCK_EXPORT)); + else + $boolExport = true; + - $arIBlockList[] = array( - 'ID' => $res['ID'], - 'NAME' => $res['NAME'], - 'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'], - 'IBLOCK_EXPORT' => $boolExport, - 'PROPERTIES' => $properties, - 'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null, - 'SITE_LIST' => '('.implode(' ',$arSiteList).')', - ); + $arIBlockList[] = array( + 'ID' => $iblock['ID'], + 'NAME' => $iblock['NAME'], + 'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'], + 'IBLOCK_EXPORT' => $boolExport, + 'PROPERTIES_SKU' => $propertiesSKU, + 'PROPERTIES_PRODUCT' => $propertiesProduct, + 'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU, + 'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct, + 'SITE_LIST' => '('.implode(' ',$arSiteList).')', + ); - if ($boolExport) - $intCountChecked++; - $intCountAvailIBlock++; + if ($boolExport) + $intCountChecked++; + $intCountAvailIBlock++; } } } @@ -78,99 +133,141 @@ if (!empty($oldValues)) { ?> - - - - - - + + + + + + +
-
+ Выбрать все инфоблоки + > +
+
+
+ + $arIBlock):?> +
+
+ + ]" + id="IBLOCK_EXPORT" + value="" + + onclick="checkOne(this,);" + > +
+
+
+ > + + + + + + + + + + + $property): ?> + + + - - - - - - - - - $arIBlock) - { - ?> - - - - - - - -
+
Выгружаемое свойство
-
-   -
+
Свойство товара
+
+
Свойство торгового предложения
+
+ -
-
- - - > - - -   -
- - - - ]" - id="IBLOCK_EXPORT" - value="" - - onclick="checkOne(this,);" - > - - - " + name="IBLOCK_PROPERTY_PRODUCT[][]" + class="property-export" + onchange="propertyChange(this);"> + + - - -
+ + +
+ +
+
+
+ + + + + + +
-
-
+

Date: Mon, 16 Sep 2013 15:37:22 +0400 Subject: [PATCH 2/5] It update old profiles to new format --- intaro.intarocrm/update.php | 109 ++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 intaro.intarocrm/update.php diff --git a/intaro.intarocrm/update.php b/intaro.intarocrm/update.php new file mode 100644 index 00000000..29166cfb --- /dev/null +++ b/intaro.intarocrm/update.php @@ -0,0 +1,109 @@ + "Y", "FILE_NAME" => "intarocrm") +); +while ($arProfile = $dbProfile->Fetch()) +{ + $PROFILE_ID = intval($arProfile["ID"]); + + parse_str($arProfile['SETUP_VARS']); + + $propertiesSKU = Array(); + $propertiesProduct = Array(); + + foreach ($IBLOCK_EXPORT as $iblock) { + + $propertiesSKU[$iblock] = Array( + "article" => null, + "manufacturer" => null, + "color" => null, + "weight" => null, + "size" => null, + ); + + $propertiesProduct[$iblock] = Array( + "article" => $IBLOCK_PROPERTY_ARTICLE[$iblock], + "manufacturer" => null, + "color" => null, + "weight" => null, + "size" => null, + ); + } + + $strVars = GetProfileSetupVars($IBLOCK_EXPORT, $propertiesProduct, $propertiesSKU, $SETUP_FILE_NAME); + + CCatalogExport::Update( + $PROFILE_ID, + array( + "SETUP_VARS" => $strVars + ) + ); + + +} + +function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename) { + + $strVars = ""; + foreach ($iblocks as $key => $val) + $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; + foreach ($propertiesSKU as $iblock => $arr) + foreach ($arr as $id => $val) + $strVars .= 'IBLOCK_PROPERTY_SKU[' . $iblock . '][' . $id . ']=' . $val . '&'; + foreach ($propertiesProduct as $iblock => $arr) + foreach ($arr as $id => $val) + $strVars .= 'IBLOCK_PROPERTY_PRODUCT[' . $iblock . '][' . $id . ']=' . $val . '&'; + + $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); + + return $strVars; +} From d058783a601875fe6ecd59d3786ac25631d40ac8 Mon Sep 17 00:00:00 2001 From: "m.korolev" Date: Mon, 23 Sep 2013 18:05:37 +0400 Subject: [PATCH 3/5] Add translations to ICML export --- intaro.intarocrm/export/export_setup.php | 6 +++--- intaro.intarocrm/install/step5.php | 4 ++-- intaro.intarocrm/lang/ru/icml_export_setup.php | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/intaro.intarocrm/export/export_setup.php b/intaro.intarocrm/export/export_setup.php index e7da7e4c..008ddf9a 100644 --- a/intaro.intarocrm/export/export_setup.php +++ b/intaro.intarocrm/export/export_setup.php @@ -67,7 +67,7 @@ if ($STEP==1) } ?> -

Настройки инфоблоков

+



- Выбрать все инфоблоки +
-

Настройки экспорта

+



-

Настройки инфоблоков

+



- Выбрать все инфоблоки + \ No newline at end of file From 5265c5d5c8fe9bc225e24818f1313e87c1992c4b Mon Sep 17 00:00:00 2001 From: "m.korolev" Date: Mon, 23 Sep 2013 18:16:26 +0400 Subject: [PATCH 4/5] Delete update.php --- intaro.intarocrm/update.php | 109 ------------------------------------ 1 file changed, 109 deletions(-) delete mode 100644 intaro.intarocrm/update.php diff --git a/intaro.intarocrm/update.php b/intaro.intarocrm/update.php deleted file mode 100644 index 29166cfb..00000000 --- a/intaro.intarocrm/update.php +++ /dev/null @@ -1,109 +0,0 @@ - "Y", "FILE_NAME" => "intarocrm") -); -while ($arProfile = $dbProfile->Fetch()) -{ - $PROFILE_ID = intval($arProfile["ID"]); - - parse_str($arProfile['SETUP_VARS']); - - $propertiesSKU = Array(); - $propertiesProduct = Array(); - - foreach ($IBLOCK_EXPORT as $iblock) { - - $propertiesSKU[$iblock] = Array( - "article" => null, - "manufacturer" => null, - "color" => null, - "weight" => null, - "size" => null, - ); - - $propertiesProduct[$iblock] = Array( - "article" => $IBLOCK_PROPERTY_ARTICLE[$iblock], - "manufacturer" => null, - "color" => null, - "weight" => null, - "size" => null, - ); - } - - $strVars = GetProfileSetupVars($IBLOCK_EXPORT, $propertiesProduct, $propertiesSKU, $SETUP_FILE_NAME); - - CCatalogExport::Update( - $PROFILE_ID, - array( - "SETUP_VARS" => $strVars - ) - ); - - -} - -function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename) { - - $strVars = ""; - foreach ($iblocks as $key => $val) - $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; - foreach ($propertiesSKU as $iblock => $arr) - foreach ($arr as $id => $val) - $strVars .= 'IBLOCK_PROPERTY_SKU[' . $iblock . '][' . $id . ']=' . $val . '&'; - foreach ($propertiesProduct as $iblock => $arr) - foreach ($arr as $id => $val) - $strVars .= 'IBLOCK_PROPERTY_PRODUCT[' . $iblock . '][' . $id . ']=' . $val . '&'; - - $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); - - return $strVars; -} From a6f94494c778e7a90d04f38633998a52013e496b Mon Sep 17 00:00:00 2001 From: "m.korolev" Date: Mon, 23 Sep 2013 18:27:47 +0400 Subject: [PATCH 5/5] fix JavaScript in step 5 --- intaro.intarocrm/install/step5.php | 71 ++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/intaro.intarocrm/install/step5.php b/intaro.intarocrm/install/step5.php index 82f7c660..a3389bcb 100644 --- a/intaro.intarocrm/install/step5.php +++ b/intaro.intarocrm/install/step5.php @@ -312,29 +312,74 @@ if (!empty($oldValues)) {