1
0
mirror of synced 2024-11-25 14:56:09 +03:00

Merge branch 'exportICMLSize' of github.com:intarocrm/bitrix-module into fullExport

This commit is contained in:
Grisha Pomadchin 2014-01-28 10:23:59 +04:00
commit 13a91ebf6a
5 changed files with 610 additions and 146 deletions

View File

@ -8,7 +8,9 @@ class ICMLLoader {
public $iblocks;
public $filename;
public $propertiesSKU;
public $propertiesUnitSKU;
public $propertiesProduct;
public $propertiesUnitProduct;
public $application;
public $encoding = 'utf-8';
public $encodingDefault = 'utf-8';
@ -21,6 +23,15 @@ class ICMLLoader {
protected $logFile = '/bitrix/catalog_export/i_crm_load_log.txt';
protected $fpLog;
protected $measurement = array (
'mm' => 1,
'cm' => 10,
'm' => 1000,
'mg' => 0.001,
'g' => 1,
'kg' => 1000,
);
public function Load()
{
global $USER;
@ -356,8 +367,14 @@ class ICMLLoader {
if (isset ($product["PROPERTY_" . $propProduct . "_NAME"]))
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"];
elseif (isset ($product[$propProduct]))
$resPropertiesProduct[$key] = $product[$propProduct];
else
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"];
if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
$resPropertiesProduct[$key] *= $this->measurement[$this->propertiesUnitProduct[$id][$key]];
}
}
}
@ -382,6 +399,11 @@ class ICMLLoader {
foreach ($product['offers'] as $offer) {
if ($product["ID"] == 33)
{
$a = 10;
}
$offer['PRODUCT_ID'] = $product["ID"];
$offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
$offer['PICTURE'] = $product["PICTURE"];
@ -396,13 +418,20 @@ class ICMLLoader {
if ($propSKU != "") {
if (isset ($product["PROPERTY_" . $propSKU . "_NAME"]))
$offer[$key] = $product["PROPERTY_" . $propSKU . "_NAME"];
if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"]))
$offer[$key] = $offer["PROPERTY_" . $propSKU . "_NAME"];
elseif (isset ($offer[$propSKU]))
$offer[$key] = $offer[$propSKU];
else
$offer[$key] = $product["PROPERTY_" . $propSKU . "_VALUE"];
$offer[$key] = $offer["PROPERTY_" . $propSKU . "_VALUE"];
if (array_key_exists($key, $this->propertiesUnitSKU[$id])) {
$offer[$key] *= $this->measurement[$this->propertiesUnitSKU[$id][$key]];
}
}
}
foreach ($resPropertiesProduct as $key => $propProduct) {
if ($this->propertiesProduct[$id][$key] != "" && !isset($offer[$key]))
$offer[$key] = $propProduct;
@ -421,9 +450,10 @@ class ICMLLoader {
$product['QUANTITY'] = $product["CATALOG_QUANTITY"];
foreach ($resPropertiesProduct as $key => $propProduct) {
if ($this->propertiesProduct[$id][$key] != "")
if ($this->propertiesProduct[$id][$key] != "") {
$product[$key] = $propProduct;
}
}
$stringOffers .= $this->BuildOffer($product, $categories, $iblock, $allCategories);
}
@ -489,6 +519,10 @@ class ICMLLoader {
if ($propProduct != "" && $arOffer[$key] != null)
$offer .= "<" . $key . ">" . $this->PrepareValue($arOffer[$key]) . "</" . $key . ">\n";
}
foreach ($this->propertiesSKU[$iblock['IBLOCK_DB']['ID']] as $key => $propProduct) {
if ($propProduct != "" && $arOffer[$key] != null)
$offer .= "<" . $key . ">" . $this->PrepareValue($arOffer[$key]) . "</" . $key . ">\n";
}
$offer.= "</offer>\n";
return $offer;

View File

@ -16,9 +16,20 @@ $iblockProperties = Array(
"color" =>"color",
"weight" => "weight",
"size" => "size",
"length" => "length",
"width" => "width",
"height" => "height",
);
$IBLOCK_PROPERTY_SKU = array();
$IBLOCK_PROPERTY_UNIT_SKU = array();
foreach ($iblockProperties as $prop) {
$skuUnitProps = ('IBLOCK_PROPERTY_UNIT_SKU' . "_" . $prop);
$skuUnitProps = $$skuUnitProps;
foreach ($skuUnitProps as $iblock => $val) {
$IBLOCK_PROPERTY_UNIT_SKU[$iblock][$prop] = $val;
}
$skuProps = ('IBLOCK_PROPERTY_SKU' . "_" . $prop);
$skuProps = $$skuProps;
foreach ($skuProps as $iblock => $val) {
@ -26,10 +37,18 @@ foreach ($iblockProperties as $prop) {
}
}
$IBLOCK_PROPERTY_PRODUCT = array();
$IBLOCK_PROPERTY_UNIT_PRODUCT = array();
foreach ($iblockProperties as $prop) {
$skuProps = "IBLOCK_PROPERTY_PRODUCT" . "_" . $prop;
$skuProps = $$skuProps;
foreach ($skuProps as $iblock => $val) {
$productUnitProps = "IBLOCK_PROPERTY_UNIT_PRODUCT" . "_" . $prop;
$productUnitProps = $$productUnitProps;
foreach ($productUnitProps as $iblock => $val) {
$IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock][$prop] = $val;
}
$productProps = "IBLOCK_PROPERTY_PRODUCT" . "_" . $prop;
$productProps = $$productProps;
foreach ($productProps as $iblock => $val) {
$IBLOCK_PROPERTY_PRODUCT[$iblock][$prop] = $val;
}
}
@ -38,7 +57,9 @@ foreach ($iblockProperties as $prop) {
$loader = new ICMLLoader();
$loader->iblocks = $IBLOCK_EXPORT;
$loader->propertiesSKU = $IBLOCK_PROPERTY_SKU;
$loader->propertiesUnitSKU = $IBLOCK_PROPERTY_UNIT_SKU;
$loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT;
$loader->propertiesUnitProduct = $IBLOCK_PROPERTY_UNIT_PRODUCT;
$loader->filename = $SETUP_FILE_NAME;
$loader->application = $APPLICATION;
$loader->Load();

View File

@ -4,8 +4,11 @@ $iblockProperties = Array(
"article" => "article",
"manufacturer" => "manufacturer",
"color" =>"color",
"weight" => "weight",
"size" => "size",
"weight" => "weight",
"length" => "length",
"width" => "width",
"height" => "height",
);
if(!check_bitrix_sessid()) return;
@ -15,7 +18,6 @@ __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']))
@ -24,16 +26,26 @@ if (($ACTION == 'EXPORT' || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY'
$IBLOCK_EXPORT = $arOldSetupVars['IBLOCK_EXPORT'];
$IBLOCK_PROPERTY_SKU = array();
$IBLOCK_PROPERTY_UNIT_SKU = array();
foreach ($iblockProperties as $prop) {
foreach ($arOldSetupVars['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) {
$IBLOCK_PROPERTY_SKU[$iblock][$prop] = $val;
}
foreach ($arOldSetupVars['IBLOCK_PROPERTY_UNIT_SKU'. '_' . $prop] as $iblock => $val) {
$IBLOCK_PROPERTY_UNIT_SKU[$iblock][$prop] = $val;
}
}
$IBLOCK_PROPERTY_PRODUCT = array();
$IBLOCK_PROPERTY_UNIT_PRODUCT = array();
foreach ($iblockProperties as $prop) {
foreach ($arOldSetupVars['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) {
$IBLOCK_PROPERTY_PRODUCT[$iblock][$prop] = $val;
}
foreach ($arOldSetupVars['IBLOCK_PROPERTY_UNIT_PRODUCT'. '_' . $prop] as $iblock => $val) {
$IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock][$prop] = $val;
}
}
}
@ -97,24 +109,56 @@ if ($STEP==1)
"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"),
"weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"),
"length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"),
"width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"),
"height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"),
);
$iblockFieldsName = Array(
"weight" => Array("code" => "catalog_size" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'),
"length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'),
"width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'),
"height" => Array("code" => "catalog_height" , "name" => GetMessage("SELECT_HEIGHT_PROPERTY_NAME"), 'unit' => 'length'),
);
$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"),
"weight" => Array("WEIGHT", "VES", "VEC"),
"length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"),
);
$units = Array(
'length' => Array(
'mm' => GetMessage("UNIT_MEASUREMENT_MM"),
'cm' => GetMessage("UNIT_MEASUREMENT_CM"),
'm' => GetMessage("UNIT_MEASUREMENT_M"),
),
'mass' => Array(
'mg' => GetMessage("UNIT_MEASUREMENT_MG"),
'g' => GetMessage("UNIT_MEASUREMENT_G"),
'kg' => GetMessage("UNIT_MEASUREMENT_KG"),
)
);
$hintUnit = Array(
'length' => 'mm',
'mass' => 'g'
);
$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 ($iblock = $db_res->Fetch())
{
if ($arCatalog = CCatalog::GetByIDExt($iblock["ID"]))
@ -136,6 +180,13 @@ if ($STEP==1)
$oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key];
}
}
$oldPropertyUnitSKU = null;
if (isset($IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitSKU[$key] = $IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']][$key];
}
}
}
@ -151,6 +202,13 @@ if ($STEP==1)
}
}
$oldPropertyUnitProduct = null;
if (isset($IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitProduct[$key] = $IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']][$key];
}
}
$arSiteList = array();
$rsSites = CIBlock::GetSite($iblock["ID"]);
while ($arSite = $rsSites->Fetch())
@ -172,7 +230,9 @@ if ($STEP==1)
'PROPERTIES_SKU' => $propertiesSKU,
'PROPERTIES_PRODUCT' => $propertiesProduct,
'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU,
'OLD_PROPERTY_UNIT_SKU_SELECT' => $oldPropertyUnitSKU,
'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct,
'OLD_PROPERTY_UNIT_PRODUCT_SELECT' => $oldPropertyUnitProduct,
'SITE_LIST' => '('.implode(' ',$arSiteList).')',
);
@ -190,9 +250,6 @@ if ($STEP==1)
$boolAll = true;
}
?>
<font class="text" style="font-weight: bold;"><?=GetMessage("CHECK_ALL_INFOBLOCKS");?></font>
@ -242,11 +299,14 @@ if ($STEP==1)
<tbody>
<? foreach ($iblockPropertiesName as $key => $property): ?>
<? $productSelected = false;?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
<? echo htmlspecialcharsex($property); ?>
</td>
<td class="adm-list-table-cell">
<select
style="width: 200px;"
@ -255,6 +315,39 @@ if ($STEP==1)
class="property-export"
onchange="propertyChange(this);">
<option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName) && $arIBlock['PROPERTIES_SKU'] == null) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
<? if ($keyField == $key): ?>
<option value="<?=$field['code'];?>"
<?
if ($arIBlock['OLD_PROPERTY_PRODUCT_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'][$key] ) {
echo " selected";
$productSelected = true;
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($field['code'] == $hint ) {
echo " selected";
$productSelected = true;
break;
}
}
}
?>
>
<?=$field['name'];?>
</option>
<? endif; ?>
<? endforeach;?>
</optgroup>
<optgroup label="<?=GetMessage("SELECT_PROPERTY_NAME");?>">
<?endif; ?>
<? foreach ($arIBlock['PROPERTIES_PRODUCT'] as $prop): ?>
<option value="<?=$prop['CODE'] ?>"
<?
@ -277,8 +370,43 @@ if ($STEP==1)
<?=$prop["NAME"];?>
</option>
<? endforeach;?>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)){?>
</optgroup>
<?}?>
</select>
<?if (array_key_exists($key, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="IBLOCK_PROPERTY_UNIT_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_UNIT_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
>
<? foreach ($units as $unitTypeName => $unitType): ?>
<? if ($unitTypeName == $iblockFieldsName[$key]['unit']): ?>
<? foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit;?>"
<?
if ($arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'] != null) {
if ($keyUnit == $arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'][$key] ) {
echo " selected";
}
} else {
if ($keyUnit == $hintUnit[$unitTypeName]) {
echo " selected";
}
}
?>
>
<?=$unit?>
</option>
<? endforeach;?>
<?endif; ?>
<? endforeach;?>
</select>
<?endif; ?>
</td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell">
<select
@ -289,6 +417,39 @@ if ($STEP==1)
onchange="propertyChange(this);">
<option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
<? if ($keyField == $key) :?>
<option value="<?=$field['code'];?>"
<?
if (!$productSelected) {
if ($arIBlock['OLD_PROPERTY_SKU_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($field['code'] == $hint ) {
echo " selected";
break;
}
}
}
}
?>
>
<?=$field['name'];?>
</option>
<? endif; ?>
<? endforeach;?>
</optgroup>
<optgroup label="<?=GetMessage("SELECT_PROPERTY_NAME");?>">
<? endif; ?>
<? foreach ($arIBlock['PROPERTIES_SKU'] as $prop): ?>
<option value="<?=$prop['CODE'] ?>"
<?
@ -311,10 +472,45 @@ if ($STEP==1)
<?=$prop["NAME"];?>
</option>
<? endforeach;?>
<? if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) : ?>
</optgroup>
<? endif; ?>
</select>
<?if (array_key_exists($key, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="IBLOCK_PROPERTY_UNIT_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_UNIT_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
>
<? foreach ($units as $unitTypeName => $unitType): ?>
<? if ($unitTypeName == $iblockFieldsName[$key]['unit']): ?>
<? foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit;?>"
<?
if ($arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'] != null) {
if ($keyUnit == $arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
if ($keyUnit == $hintUnit[$unitTypeName]) {
echo " selected";
}
}
?>
>
<?=$unit?>
</option>
<? endforeach;?>
<?endif; ?>
<? endforeach;?>
</select>
<?endif; ?>
</td>
<? endif;?>
</tr>
<? endforeach;?>
</tbody>
</table>
@ -444,7 +640,9 @@ if ($STEP==1)
$vals = "SETUP_FILE_NAME,IBLOCK_EXPORT";
foreach ($iblockProperties as $val) {
$vals .= ",IBLOCK_PROPERTY_SKU_" . $val;
$vals .= ",IBLOCK_PROPERTY_UNIT_SKU_" . $val;
$vals .= ",IBLOCK_PROPERTY_PRODUCT_" . $val;
$vals .= ",IBLOCK_PROPERTY_UNIT_PRODUCT_" . $val;
}
?>

View File

@ -942,20 +942,31 @@ class intaro_intarocrm extends CModule {
"color" =>"color",
"weight" => "weight",
"size" => "size",
"length" => "length",
"width" => "width",
"height" => "height",
);
$propertiesSKU = array();
$propertiesUnitSKU = array();
foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) {
$propertiesSKU[$iblock][$prop] = $val;
}
foreach ($_POST['IBLOCK_PROPERTY_UNIT_SKU'. '_' . $prop] as $iblock => $val) {
$propertiesUnitSKU[$iblock][$prop] = $val;
}
}
$propertiesProduct = array();
$propertiesUnitProduct = array();
foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) {
$propertiesProduct[$iblock][$prop] = $val;
}
foreach ($_POST['IBLOCK_PROPERTY_UNIT_PRODUCT'. '_' . $prop] as $iblock => $val) {
$propertiesUnitProduct[$iblock][$prop] = $val;
}
}
if (!isset($_POST['SETUP_FILE_NAME']))
@ -984,7 +995,9 @@ class intaro_intarocrm extends CModule {
$arOldValues = Array(
'IBLOCK_EXPORT' => $iblocks,
'IBLOCK_PROPERTY_SKU' => $propertiesSKU,
'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU,
'IBLOCK_PROPERTY_PRODUCT' => $propertiesProduct,
'IBLOCK_PROPERTY_UNIT_PRODUCT' => $propertiesUnitProduct,
'SETUP_FILE_NAME' => $filename,
'SETUP_PROFILE_NAME' => $profileName
);
@ -992,7 +1005,7 @@ class intaro_intarocrm extends CModule {
$oldValues = $arOldValues;
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php'
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php'
);
return;
}
@ -1009,7 +1022,9 @@ class intaro_intarocrm extends CModule {
$loader = new ICMLLoader();
$loader->iblocks = $iblocks;
$loader->propertiesUnitProduct = $propertiesUnitProduct;
$loader->propertiesProduct = $propertiesProduct;
$loader->propertiesUnitSKU = $propertiesUnitSKU;
$loader->propertiesSKU = $propertiesSKU;
$loader->filename = $filename;
$loader->application = $APPLICATION;
@ -1028,7 +1043,7 @@ class intaro_intarocrm extends CModule {
}
}
}
$ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename);
$ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesUnitProduct, $propertiesSKU, $propertiesUnitSKU, $filename);
$PROFILE_ID = CCatalogExport::Add(array(
"LAST_USE" => false,
"FILE_NAME" => $this->INTARO_CRM_EXPORT,
@ -1209,7 +1224,7 @@ class intaro_intarocrm extends CModule {
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php');
}
function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename) {
function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesUnitProduct, $propertiesSKU, $propertiesUnitSKU, $filename) {
// Get string like IBLOCK_EXPORT[0]=3&
// IBLOCK_EXPORT[1]=6&
// IBLOCK_PROPERTY_ARTICLE[0]=ARTICLE&
@ -1223,9 +1238,15 @@ class intaro_intarocrm extends CModule {
foreach ($propertiesSKU as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesUnitSKU as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesProduct as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesUnitProduct as $iblock => $arr)
foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
$strVars .= 'SETUP_FILE_NAME=' . urlencode($filename);

View File

@ -12,7 +12,9 @@ global $oldValues;
if (!empty($oldValues)) {
$IBLOCK_EXPORT = $oldValues['IBLOCK_EXPORT'];
$IBLOCK_PROPERTY_SKU = $oldValues['IBLOCK_PROPERTY_SKU'];
$IBLOCK_PROPERTY_UNIT_SKU = $oldValues['IBLOCK_PROPERTY_UNIT_SKU'];
$IBLOCK_PROPERTY_PRODUCT = $oldValues['IBLOCK_PROPERTY_PRODUCT'];
$IBLOCK_PROPERTY_UNIT_PRODUCT = $oldValues['IBLOCK_PROPERTY_UNIT_PRODUCT'];
$SETUP_FILE_NAME = $oldValues['SETUP_FILE_NAME'];
$SETUP_PROFILE_NAME = $oldValues['SETUP_PROFILE_NAME'];
}
@ -38,18 +40,51 @@ if (!empty($oldValues)) {
"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"),
"weight" => GetMessage("PROPERTY_WEIGHT_HEADER_NAME"),
"length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"),
"width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"),
"height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"),
);
$iblockFieldsName = Array(
"weight" => Array("code" => "catalog_size" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'),
"length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'),
"width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'),
"height" => Array("code" => "catalog_height" , "name" => GetMessage("SELECT_HEIGHT_PROPERTY_NAME"), 'unit' => 'length'),
);
$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"),
"weight" => Array("WEIGHT", "VES", "VEC"),
"length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"),
);
$units = Array(
'length' => Array(
'mm' => GetMessage("UNIT_MEASUREMENT_MM"),
'cm' => GetMessage("UNIT_MEASUREMENT_CM"),
'm' => GetMessage("UNIT_MEASUREMENT_M"),
),
'mass' => Array(
'mg' => GetMessage("UNIT_MEASUREMENT_MG"),
'g' => GetMessage("UNIT_MEASUREMENT_G"),
'kg' => GetMessage("UNIT_MEASUREMENT_KG"),
)
);
$hintUnit = Array(
'length' => 'mm',
'mass' => 'g'
);
$boolAll = false;
$intCountChecked = 0;
@ -77,6 +112,12 @@ if (!empty($oldValues)) {
$oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key];
}
}
$oldPropertyUnitSKU = null;
if (isset($IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitSKU[$key] = $IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']][$key];
}
}
}
@ -92,6 +133,13 @@ if (!empty($oldValues)) {
}
}
$oldPropertyUnitProduct = null;
if (isset($IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitProduct[$key] = $IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']][$key];
}
}
$arSiteList = array();
$rsSites = CIBlock::GetSite($iblock["ID"]);
while ($arSite = $rsSites->Fetch())
@ -113,7 +161,9 @@ if (!empty($oldValues)) {
'PROPERTIES_SKU' => $propertiesSKU,
'PROPERTIES_PRODUCT' => $propertiesProduct,
'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU,
'OLD_PROPERTY_UNIT_SKU_SELECT' => $oldPropertyUnitSKU,
'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct,
'OLD_PROPERTY_UNIT_PRODUCT_SELECT' => $oldPropertyUnitProduct,
'SITE_LIST' => '('.implode(' ',$arSiteList).')',
);
@ -180,7 +230,9 @@ if (!empty($oldValues)) {
<tbody>
<? foreach ($iblockPropertiesName as $key => $property): ?>
<? $productSelected = false;?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
<? echo htmlspecialcharsex($property); ?>
@ -193,6 +245,39 @@ if (!empty($oldValues)) {
class="property-export"
onchange="propertyChange(this);">
<option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName) && $arIBlock['PROPERTIES_SKU'] == null) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
<? if ($keyField == $key): ?>
<option value="<?=$field['code'];?>"
<?
if ($arIBlock['OLD_PROPERTY_PRODUCT_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'][$key] ) {
echo " selected";
$productSelected = true;
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($field['code'] == $hint ) {
echo " selected";
$productSelected = true;
break;
}
}
}
?>
>
<?=$field['name'];?>
</option>
<? endif; ?>
<? endforeach;?>
</optgroup>
<optgroup label="<?=GetMessage("SELECT_PROPERTY_NAME");?>">
<?endif; ?>
<? foreach ($arIBlock['PROPERTIES_PRODUCT'] as $prop): ?>
<option value="<?=$prop['CODE'] ?>"
<?
@ -215,7 +300,40 @@ if (!empty($oldValues)) {
<?=$prop["NAME"];?>
</option>
<? endforeach;?>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)){?>
</optgroup>
<?}?>
</select>
<?if (array_key_exists($key, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="IBLOCK_PROPERTY_UNIT_PRODUCT_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_UNIT_PRODUCT_<?=$key?>[<?=$arIBlock["ID"]?>]"
>
<? foreach ($units as $unitTypeName => $unitType): ?>
<? if ($unitTypeName == $iblockFieldsName[$key]['unit']): ?>
<? foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit;?>"
<?
if ($arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'] != null) {
if ($keyUnit == $arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'][$key] ) {
echo " selected";
}
} else {
if ($keyUnit == $hintUnit[$unitTypeName]) {
echo " selected";
}
}
?>
>
<?=$unit?>
</option>
<? endforeach;?>
<?endif; ?>
<? endforeach;?>
</select>
<?endif; ?>
</td>
<? if ($arIBlock['PROPERTIES_SKU'] != null): ?>
<td class="adm-list-table-cell">
@ -227,6 +345,38 @@ if (!empty($oldValues)) {
onchange="propertyChange(this);">
<option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
<? if ($keyField == $key) :?>
<option value="<?=$field['code'];?>"
<?
if (!$productSelected) {
if ($arIBlock['OLD_PROPERTY_SKU_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
foreach ($iblockPropertiesHint[$key] as $hint) {
if ($field['code'] == $hint ) {
echo " selected";
break;
}
}
}
}?>
>
<?=$field['name'];?>
</option>
<? endif; ?>
<? endforeach;?>
</optgroup>
<optgroup label="<?=GetMessage("SELECT_PROPERTY_NAME");?>">
<? endif; ?>
<? foreach ($arIBlock['PROPERTIES_SKU'] as $prop): ?>
<option value="<?=$prop['CODE'] ?>"
<?
@ -249,7 +399,40 @@ if (!empty($oldValues)) {
<?=$prop["NAME"];?>
</option>
<? endforeach;?>
<? if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) : ?>
</optgroup>
<? endif; ?>
</select>
<?if (array_key_exists($key, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="IBLOCK_PROPERTY_UNIT_SKU_<?=$key?><?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_UNIT_SKU_<?=$key?>[<?=$arIBlock["ID"]?>]"
>
<? foreach ($units as $unitTypeName => $unitType): ?>
<? if ($unitTypeName == $iblockFieldsName[$key]['unit']): ?>
<? foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit;?>"
<?
if ($arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'] != null) {
if ($keyUnit == $arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'][$key] ) {
echo " selected";
}
} else {
if ($keyUnit == $hintUnit[$unitTypeName]) {
echo " selected";
}
}
?>
>
<?=$unit?>
</option>
<? endforeach;?>
<?endif; ?>
<? endforeach;?>
</select>
<?endif; ?>
</td>
<? endif;?>
</tr>
@ -381,6 +564,13 @@ if (!empty($oldValues)) {
BX(obj.id.replace('PRODUCT','SKU')).value = 'none';
}
};
function checkProfile(obj)
{
if (obj.value !== 'none')
$('#profile-field').show();
else
$('#profile-field').hide();
};
</script>