1
0
mirror of synced 2024-11-22 13:26:10 +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")) if (!CModule::IncludeModule("intaro.intarocrm"))
return; 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 = new ICMLLoader();
$loader->iblocks = $IBLOCK_EXPORT; $loader->iblocks = $IBLOCK_EXPORT;
$loader->propertiesSKU = $IBLOCK_PROPERTY_SKU; $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; 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 (($ACTION == 'EXPORT' || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1)
{ {
if (isset($arOldSetupVars['SETUP_FILE_NAME'])) if (isset($arOldSetupVars['SETUP_FILE_NAME']))
$SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME']; $SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME'];
if (isset($arOldSetupVars['SETUP_PROFILE_NAME'])) if (isset($arOldSetupVars['SETUP_PROFILE_NAME']))
$SETUP_PROFILE_NAME = $arOldSetupVars['SETUP_PROFILE_NAME']; $SETUP_PROFILE_NAME = $arOldSetupVars['SETUP_PROFILE_NAME'];
if (isset($arOldSetupVars['IBLOCK_EXPORT'])) if (isset($arOldSetupVars['IBLOCK_EXPORT']))
$IBLOCK_EXPORT = $arOldSetupVars['IBLOCK_EXPORT']; $IBLOCK_EXPORT = $arOldSetupVars['IBLOCK_EXPORT'];
if (isset($arOldSetupVars['IBLOCK_PROPERTY_SKU']))
$IBLOCK_PROPERTY_SKU = $arOldSetupVars['IBLOCK_PROPERTY_SKU']; $IBLOCK_PROPERTY_SKU = array();
if (isset($arOldSetupVars['IBLOCK_PROPERTY_PRODUCT'])) foreach ($iblockProperties as $prop) {
$IBLOCK_PROPERTY_PRODUCT = $arOldSetupVars['IBLOCK_PROPERTY_PRODUCT']; 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) if ($STEP>1)
{ {
@ -76,11 +94,11 @@ if ($STEP==1)
} }
$iblockPropertiesName = Array( $iblockPropertiesName = Array(
"article" => "Артикул", "article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"),
"manufacturer" => "Производитель", "manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"),
"color" => "Цвет", "color" => GetMessage("PROPERTY_COLOR_HEADER_NAME"),
"weight" => "Вес", "weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"),
"size" => "Размер", "size" => GetMessage("PROPERTY_SIZE_HEADER_NAME"),
); );
$iblockPropertiesHint = Array( $iblockPropertiesHint = Array(
@ -209,14 +227,14 @@ if ($STEP==1)
<thead> <thead>
<tr class="adm-list-table-header"> <tr class="adm-list-table-header">
<td class="adm-list-table-cell"> <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>
<td class="adm-list-table-cell"> <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> </td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?> <? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell"> <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> </td>
<? endif;?> <? endif;?>
</tr> </tr>
@ -233,7 +251,7 @@ if ($STEP==1)
<select <select
style="width: 200px;" style="width: 200px;"
id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>" id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_PRODUCT[<?=$arIBlock["ID"]?>][<?=$key?>]" name="IBLOCK_PROPERTY_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export" class="property-export"
onchange="propertyChange(this);"> onchange="propertyChange(this);">
<option value=""></option> <option value=""></option>
@ -266,7 +284,7 @@ if ($STEP==1)
<select <select
style="width: 200px;" style="width: 200px;"
id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>" id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_SKU[<?=$arIBlock["ID"]?>][<?=$key?>]" name="IBLOCK_PROPERTY_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export" class="property-export"
onchange="propertyChange(this);"> onchange="propertyChange(this);">
@ -422,11 +440,19 @@ if ($STEP==1)
<?//Следующие переменные должны быть обязательно установлены?> <?//Следующие переменные должны быть обязательно установлены?>
<?=bitrix_sessid_post();?> <?=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="lang" value="<?echo LANGUAGE_ID ?>">
<input type="hidden" name="ACT_FILE" value="<?echo htmlspecialcharsbx($_REQUEST["ACT_FILE"]) ?>"> <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="ACTION" value="<?echo htmlspecialcharsbx($ACTION) ?>">
<input type="hidden" name="STEP" value="<?echo intval($STEP) + 1 ?>"> <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")?>"> <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 else
$iblocks = $_POST['IBLOCK_EXPORT']; $iblocks = $_POST['IBLOCK_EXPORT'];
if(!isset($_POST['IBLOCK_PROPERTY_SKU'])) $iblockProperties = Array(
$arResult['errCode'] = 'ERR_FIELDS_SKU'; "article" => "article",
else "manufacturer" => "manufacturer",
$propertiesSKU = $_POST['IBLOCK_PROPERTY_SKU']; "color" =>"color",
"weight" => "weight",
"size" => "size",
);
if(!isset($_POST['IBLOCK_PROPERTY_PRODUCT'])) $propertiesSKU = array();
$arResult['errCode'] = 'ERR_FIELDS_PRODUCT'; foreach ($iblockProperties as $prop) {
else foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) {
$propertiesProduct = $_POST['IBLOCK_PROPERTY_PRODUCT']; $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'])) if (!isset($_POST['SETUP_FILE_NAME']))
$arResult['errCode'] = 'ERR_FIELDS_FILE'; $arResult['errCode'] = 'ERR_FIELDS_FILE';
@ -1091,14 +1103,13 @@ class intaro_intarocrm extends CModule {
$strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&';
foreach ($propertiesSKU as $iblock => $arr) foreach ($propertiesSKU as $iblock => $arr)
foreach ($arr as $id => $val) 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 ($propertiesProduct as $iblock => $arr)
foreach ($arr as $id => $val) 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); $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename);
return $strVars; return $strVars;
} }
} }

View File

@ -35,11 +35,11 @@ if (!empty($oldValues)) {
} }
$iblockPropertiesName = Array( $iblockPropertiesName = Array(
"article" => "Артикул", "article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"),
"manufacturer" => "Производитель", "manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"),
"color" => "Цвет", "color" => GetMessage("PROPERTY_COLOR_HEADER_NAME"),
"weight" => "Вес", "weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"),
"size" => "Размер", "size" => GetMessage("PROPERTY_SIZE_HEADER_NAME"),
); );
$iblockPropertiesHint = Array( $iblockPropertiesHint = Array(
@ -165,14 +165,14 @@ if (!empty($oldValues)) {
<thead> <thead>
<tr class="adm-list-table-header"> <tr class="adm-list-table-header">
<td class="adm-list-table-cell"> <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>
<td class="adm-list-table-cell"> <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> </td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?> <? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell"> <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> </td>
<? endif;?> <? endif;?>
</tr> </tr>
@ -189,7 +189,7 @@ if (!empty($oldValues)) {
<select <select
style="width: 200px;" style="width: 200px;"
id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>" id="IBLOCK_PROPERTY_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_PRODUCT[<?=$arIBlock["ID"]?>][<?=$key?>]" name="IBLOCK_PROPERTY_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export" class="property-export"
onchange="propertyChange(this);"> onchange="propertyChange(this);">
<option value=""></option> <option value=""></option>
@ -222,7 +222,7 @@ if (!empty($oldValues)) {
<select <select
style="width: 200px;" style="width: 200px;"
id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>" id="IBLOCK_PROPERTY_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_SKU[<?=$arIBlock["ID"]?>][<?=$key?>]" name="IBLOCK_PROPERTY_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
class="property-export" class="property-export"
onchange="propertyChange(this);"> onchange="propertyChange(this);">

View File

@ -17,5 +17,12 @@ $MESS["PROFILE_NAME"] = "Имя профиля";
$MESS["SETTINGS_INFOBLOCK"] = "Настройки инфоблоков"; $MESS["SETTINGS_INFOBLOCK"] = "Настройки инфоблоков";
$MESS["SETTINGS_EXPORT"] = "Настройки экспорта"; $MESS["SETTINGS_EXPORT"] = "Настройки экспорта";
$MESS["CHECK_ALL_INFOBLOCKS"] = "Выбрать все инфоблоки "; $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"] = "Размер";
?> ?>