From b2ae04bebb383c7da1ac0c7132b315b44ad38459 Mon Sep 17 00:00:00 2001 From: "m.korolev" Date: Wed, 25 Sep 2013 20:36:49 +0400 Subject: [PATCH] fix complex array storage in bitrix --- intaro.intarocrm/export/export_run.php | 25 ++++++++ intaro.intarocrm/export/export_setup.php | 58 ++++++++++++++----- intaro.intarocrm/install/index.php | 33 +++++++---- intaro.intarocrm/install/step5.php | 20 +++---- .../lang/ru/icml_export_setup.php | 9 ++- 5 files changed, 107 insertions(+), 38 deletions(-) diff --git a/intaro.intarocrm/export/export_run.php b/intaro.intarocrm/export/export_run.php index b0ddb912..34b4f19b 100644 --- a/intaro.intarocrm/export/export_run.php +++ b/intaro.intarocrm/export/export_run.php @@ -10,6 +10,31 @@ if (!CModule::IncludeModule("catalog")) if (!CModule::IncludeModule("intaro.intarocrm")) return; +$iblockProperties = Array( + "article" => "article", + "manufacturer" => "manufacturer", + "color" =>"color", + "weight" => "weight", + "size" => "size", + ); +$IBLOCK_PROPERTY_SKU = array(); +foreach ($iblockProperties as $prop) { + $skuProps = ('IBLOCK_PROPERTY_SKU' . "_" . $prop); + $skuProps = $$skuProps; + foreach ($skuProps as $iblock => $val) { + $IBLOCK_PROPERTY_SKU[$iblock][$prop] = $val; + } +} +$IBLOCK_PROPERTY_PRODUCT = array(); +foreach ($iblockProperties as $prop) { + $skuProps = "IBLOCK_PROPERTY_PRODUCT" . "_" . $prop; + $skuProps = $$skuProps; + foreach ($skuProps as $iblock => $val) { + $IBLOCK_PROPERTY_PRODUCT[$iblock][$prop] = $val; + } +} + + $loader = new ICMLLoader(); $loader->iblocks = $IBLOCK_EXPORT; $loader->propertiesSKU = $IBLOCK_PROPERTY_SKU; diff --git a/intaro.intarocrm/export/export_setup.php b/intaro.intarocrm/export/export_setup.php index 008ddf9a..8c4e8176 100644 --- a/intaro.intarocrm/export/export_setup.php +++ b/intaro.intarocrm/export/export_setup.php @@ -1,6 +1,12 @@ "article", + "manufacturer" => "manufacturer", + "color" =>"color", + "weight" => "weight", + "size" => "size", + ); if(!check_bitrix_sessid()) return; @@ -8,19 +14,31 @@ __IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro. if (($ACTION == 'EXPORT' || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1) { + + if (isset($arOldSetupVars['SETUP_FILE_NAME'])) $SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME']; if (isset($arOldSetupVars['SETUP_PROFILE_NAME'])) $SETUP_PROFILE_NAME = $arOldSetupVars['SETUP_PROFILE_NAME']; if (isset($arOldSetupVars['IBLOCK_EXPORT'])) $IBLOCK_EXPORT = $arOldSetupVars['IBLOCK_EXPORT']; - if (isset($arOldSetupVars['IBLOCK_PROPERTY_SKU'])) - $IBLOCK_PROPERTY_SKU = $arOldSetupVars['IBLOCK_PROPERTY_SKU']; - if (isset($arOldSetupVars['IBLOCK_PROPERTY_PRODUCT'])) - $IBLOCK_PROPERTY_PRODUCT = $arOldSetupVars['IBLOCK_PROPERTY_PRODUCT']; + + $IBLOCK_PROPERTY_SKU = array(); + foreach ($iblockProperties as $prop) { + foreach ($arOldSetupVars['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) { + $IBLOCK_PROPERTY_SKU[$iblock][$prop] = $val; + } + } + $IBLOCK_PROPERTY_PRODUCT = array(); + foreach ($iblockProperties as $prop) { + foreach ($arOldSetupVars['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) { + $IBLOCK_PROPERTY_PRODUCT[$iblock][$prop] = $val; + } + } } + if ($STEP>1) { @@ -76,11 +94,11 @@ if ($STEP==1) } $iblockPropertiesName = Array( - "article" => "Артикул", - "manufacturer" => "Производитель", - "color" => "Цвет", - "weight" => "Вес", - "size" => "Размер", + "article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"), + "manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"), + "color" => GetMessage("PROPERTY_COLOR_HEADER_NAME"), + "weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"), + "size" => GetMessage("PROPERTY_SIZE_HEADER_NAME"), ); $iblockPropertiesHint = Array( @@ -209,14 +227,14 @@ if ($STEP==1) -
Выгружаемое свойство
+
-
Свойство товара
+
-
Свойство торгового предложения
+
@@ -233,7 +251,7 @@ if ($STEP==1) " - name="IBLOCK_PROPERTY_SKU[][]" + name="IBLOCK_PROPERTY_SKU_[]" class="property-export" onchange="propertyChange(this);"> @@ -422,11 +440,19 @@ if ($STEP==1) + "> - + "> diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 2a8e5cec..b587945a 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -823,15 +823,27 @@ class intaro_intarocrm extends CModule { else $iblocks = $_POST['IBLOCK_EXPORT']; - if(!isset($_POST['IBLOCK_PROPERTY_SKU'])) - $arResult['errCode'] = 'ERR_FIELDS_SKU'; - else - $propertiesSKU = $_POST['IBLOCK_PROPERTY_SKU']; + $iblockProperties = Array( + "article" => "article", + "manufacturer" => "manufacturer", + "color" =>"color", + "weight" => "weight", + "size" => "size", + ); - if(!isset($_POST['IBLOCK_PROPERTY_PRODUCT'])) - $arResult['errCode'] = 'ERR_FIELDS_PRODUCT'; - else - $propertiesProduct = $_POST['IBLOCK_PROPERTY_PRODUCT']; + $propertiesSKU = array(); + foreach ($iblockProperties as $prop) { + foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) { + $propertiesSKU[$iblock][$prop] = $val; + } + } + + $propertiesProduct = array(); + foreach ($iblockProperties as $prop) { + foreach ($_POST['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) { + $propertiesProduct[$iblock][$prop] = $val; + } + } if (!isset($_POST['SETUP_FILE_NAME'])) $arResult['errCode'] = 'ERR_FIELDS_FILE'; @@ -1091,14 +1103,13 @@ class intaro_intarocrm extends CModule { $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; foreach ($propertiesSKU as $iblock => $arr) foreach ($arr as $id => $val) - $strVars .= 'IBLOCK_PROPERTY_SKU[' . $iblock . '][' . $id . ']=' . $val . '&'; + $strVars .= 'IBLOCK_PROPERTY_SKU_' . $id . '[' . $iblock . ']=' . $val . '&'; foreach ($propertiesProduct as $iblock => $arr) foreach ($arr as $id => $val) - $strVars .= 'IBLOCK_PROPERTY_PRODUCT[' . $iblock . '][' . $id . ']=' . $val . '&'; + $strVars .= 'IBLOCK_PROPERTY_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&'; $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); return $strVars; } - } \ No newline at end of file diff --git a/intaro.intarocrm/install/step5.php b/intaro.intarocrm/install/step5.php index a3389bcb..9378847a 100644 --- a/intaro.intarocrm/install/step5.php +++ b/intaro.intarocrm/install/step5.php @@ -35,11 +35,11 @@ if (!empty($oldValues)) { } $iblockPropertiesName = Array( - "article" => "Артикул", - "manufacturer" => "Производитель", - "color" => "Цвет", - "weight" => "Вес", - "size" => "Размер", + "article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"), + "manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"), + "color" => GetMessage("PROPERTY_COLOR_HEADER_NAME"), + "weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"), + "size" => GetMessage("PROPERTY_SIZE_HEADER_NAME"), ); $iblockPropertiesHint = Array( @@ -165,14 +165,14 @@ if (!empty($oldValues)) { -
Выгружаемое свойство
+
-
Свойство товара
+
-
Свойство торгового предложения
+
@@ -189,7 +189,7 @@ if (!empty($oldValues)) { " - name="IBLOCK_PROPERTY_SKU[][]" + name="IBLOCK_PROPERTY_SKU_[]" class="property-export" onchange="propertyChange(this);"> diff --git a/intaro.intarocrm/lang/ru/icml_export_setup.php b/intaro.intarocrm/lang/ru/icml_export_setup.php index ee440a48..7dc07010 100644 --- a/intaro.intarocrm/lang/ru/icml_export_setup.php +++ b/intaro.intarocrm/lang/ru/icml_export_setup.php @@ -17,5 +17,12 @@ $MESS["PROFILE_NAME"] = "Имя профиля"; $MESS["SETTINGS_INFOBLOCK"] = "Настройки инфоблоков"; $MESS["SETTINGS_EXPORT"] = "Настройки экспорта"; $MESS["CHECK_ALL_INFOBLOCKS"] = "Выбрать все инфоблоки "; - +$MESS["LOADED_PROPERTY"] = "Выгружаемое свойство"; +$MESS["PROPERTY_PRODUCT_HEADER_NAME"] = "Свойство товара"; +$MESS["PROPERTY_OFFER_HEADER_NAME"] = "Свойство торгового предложения"; +$MESS["PROPERTY_ARTICLE_HEADER_NAME"] = "Артикул"; +$MESS["PROPERTY_MANUFACTURER_HEADER_NAME"] = "Производитель"; +$MESS["PROPERTY_COLOR_HEADER_NAME"] = "Цвет"; +$MESS["PROPERTY_WEIGHT_HEADER_NAME"] = "Вес"; +$MESS["PROPERTY_SIZE_HEADER_NAME"] = "Размер"; ?> \ No newline at end of file