1
0
mirror of synced 2024-11-22 05:16:09 +03:00

fix complex array storage in bitrix

This commit is contained in:
m.korolev 2013-09-25 20:36:49 +04:00
parent a6f94494c7
commit b2ae04bebb
5 changed files with 107 additions and 38 deletions

View File

@ -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;

View File

@ -1,6 +1,12 @@
<?
$iblockProperties = Array(
"article" => "article",
"manufacturer" => "manufacturer",
"color" =>"color",
"weight" => "weight",
"size" => "size",
);
if(!check_bitrix_sessid()) return;
@ -8,17 +14,29 @@ __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)
<thead>
<tr class="adm-list-table-header">
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">Выгружаемое свойство</div>
<div class="adm-list-table-cell-inner"><?=GetMessage("LOADED_PROPERTY");?></div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">Свойство товара</div>
<div class="adm-list-table-cell-inner"><?=GetMessage("PROPERTY_PRODUCT_HEADER_NAME");?></div>
</td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">Свойство торгового предложения</div>
<div class="adm-list-table-cell-inner"><?=GetMessage("PROPERTY_OFFER_HEADER_NAME");?></div>
</td>
<? endif;?>
</tr>
@ -233,7 +251,7 @@ if ($STEP==1)
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_PRODUCT[<?=$arIBlock["ID"]?>][<?=$key?>]"
name="IBLOCK_PROPERTY_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export"
onchange="propertyChange(this);">
<option value=""></option>
@ -266,7 +284,7 @@ if ($STEP==1)
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_SKU[<?=$arIBlock["ID"]?>][<?=$key?>]"
name="IBLOCK_PROPERTY_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export"
onchange="propertyChange(this);">
@ -422,11 +440,19 @@ if ($STEP==1)
<?//Следующие переменные должны быть обязательно установлены?>
<?=bitrix_sessid_post();?>
<?
$vals = "SETUP_FILE_NAME,IBLOCK_EXPORT";
foreach ($iblockProperties as $val) {
$vals .= ",IBLOCK_PROPERTY_SKU_" . $val;
$vals .= ",IBLOCK_PROPERTY_PRODUCT_" . $val;
}
?>
<input type="hidden" name="lang" value="<?echo LANGUAGE_ID ?>">
<input type="hidden" name="ACT_FILE" value="<?echo htmlspecialcharsbx($_REQUEST["ACT_FILE"]) ?>">
<input type="hidden" name="ACTION" value="<?echo htmlspecialcharsbx($ACTION) ?>">
<input type="hidden" name="STEP" value="<?echo intval($STEP) + 1 ?>">
<input type="hidden" name="SETUP_FIELDS_LIST" value="SETUP_FILE_NAME,IBLOCK_EXPORT,IBLOCK_PROPERTY_SKU,IBLOCK_PROPERTY_PRODUCT">
<input type="hidden" name="SETUP_FIELDS_LIST" value="<? echo $vals ?>">
<input type="submit" value="<?echo ($ACTION=="EXPORT")?GetMessage("CET_EXPORT"):GetMessage("CET_SAVE")?>">

View File

@ -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;
}
}

View File

@ -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)) {
<thead>
<tr class="adm-list-table-header">
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">Выгружаемое свойство</div>
<div class="adm-list-table-cell-inner"><?=GetMessage("LOADED_PROPERTY");?></div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">Свойство товара</div>
<div class="adm-list-table-cell-inner"><?=GetMessage("PROPERTY_PRODUCT_HEADER_NAME");?></div>
</td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">Свойство торгового предложения</div>
<div class="adm-list-table-cell-inner"><?=GetMessage("PROPERTY_OFFER_HEADER_NAME");?></div>
</td>
<? endif;?>
</tr>
@ -189,7 +189,7 @@ if (!empty($oldValues)) {
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_PRODUCT[<?=$arIBlock["ID"]?>][<?=$key?>]"
name="IBLOCK_PROPERTY_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export"
onchange="propertyChange(this);">
<option value=""></option>
@ -222,7 +222,7 @@ if (!empty($oldValues)) {
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_SKU[<?=$arIBlock["ID"]?>][<?=$key?>]"
name="IBLOCK_PROPERTY_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export"
onchange="propertyChange(this);">

View File

@ -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"] = "Размер";
?>