$arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y')), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_NAME' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'SECTION_DESCRIPTION_TYPE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => 'text'), 'SECTION_DESCRIPTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'SECTION_XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y'))), "CODE" => "clothes_offers", "XML_ID" => $iblockCodeOffers); $iblock->Update($IBLOCK_OFFERS_ID, $arFields); } if ($IBLOCK_CATALOG_ID) { $iblockCode = "clothes_" . WIZARD_SITE_ID; //IBlock fields $iblock = new CIBlock(); $arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y')), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'SECTION_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'SECTION_DESCRIPTION_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'SECTION_DESCRIPTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'SECTION_XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_CODE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y'))), "CODE" => "clothes", "XML_ID" => $iblockCode); $iblock->Update($IBLOCK_CATALOG_ID, $arFields); if ($IBLOCK_OFFERS_ID) { $ID_SKU = CCatalog::LinkSKUIBlock($IBLOCK_CATALOG_ID, $IBLOCK_OFFERS_ID); $rsCatalogs = CCatalog::GetList(array(), array('IBLOCK_ID' => $IBLOCK_OFFERS_ID), false, false, array('IBLOCK_ID')); if ($arCatalog = $rsCatalogs->Fetch()) { CCatalog::Update($IBLOCK_OFFERS_ID, array('PRODUCT_IBLOCK_ID' => $IBLOCK_CATALOG_ID, 'SKU_PROPERTY_ID' => $ID_SKU)); } else { CCatalog::Add(array('IBLOCK_ID' => $IBLOCK_OFFERS_ID, 'PRODUCT_IBLOCK_ID' => $IBLOCK_CATALOG_ID, 'SKU_PROPERTY_ID' => $ID_SKU)); } //create facet index $index = \Bitrix\Iblock\PropertyIndex\Manager::createIndexer($IBLOCK_CATALOG_ID); $index->startIndex(); $index->continueIndex(0); $index->endIndex(); $index = \Bitrix\Iblock\PropertyIndex\Manager::createIndexer($IBLOCK_OFFERS_ID); $index->startIndex(); $index->continueIndex(0); $index->endIndex(); \Bitrix\Iblock\PropertyIndex\Manager::checkAdminNotification(); } //user fields for sections $arLanguages = array(); $rsLanguage = CLanguage::GetList($by, $order, array());
$IS_CATALOG = 'Y'; $arOffersFields = array('IBLOCK_ID' => $ID, 'SUBSCRIPTION' => $SUBSCRIPTION, 'YANDEX_EXPORT' => $YANDEX_EXPORT, 'VAT_ID' => $VAT_ID); $boolFlag = $obCatalog->Update($ID, $arOffersFields); if (false == $boolFlag) { $bVarsFromForm = true; if ($ex = $APPLICATION->GetException()) { $strWarning .= $ex->GetString() . "<br>"; } } else { $boolNeedAgent = $YANDEX_EXPORT != $arCatalog['YANDEX_EXPORT']; } } else { $arOffersFields = array('IBLOCK_ID' => $ID, 'SUBSCRIPTION' => $SUBSCRIPTION, 'YANDEX_EXPORT' => $YANDEX_EXPORT, 'VAT_ID' => $VAT_ID); if (false == $arCatalog || 'P' == $arCatalog['CATALOG_TYPE']) { if ($IS_CATALOG == 'Y') { $boolFlag = $obCatalog->Add($arOffersFields); } if ($boolFlag && $arOffersFields['YANDEX_EXPORT'] == 'Y') { $boolNeedAgent = true; } } else { if ($IS_CATALOG == 'Y' || $SUBSCRIPTION == 'Y') { $boolFlag = $obCatalog->Update($ID, $arOffersFields); if ($boolFlag) { $boolNeedAgent = $YANDEX_EXPORT != $arCatalog['YANDEX_EXPORT']; } } elseif ('Y' != $IS_CATALOG && 'Y' != $SUBSCRIPTION) { $boolFlag = $obCatalog->Delete($ID); if ($boolFlag) { $boolNeedAgent == ('Y' == $arCatalog['YANDEX_EXPORT']); }
if (!CCatalog::Delete($arIBlockInfo['ID'])) { $boolFlag = false; $strWarning .= Loc::getMessage("CAT_DEL_CATALOG1").' '.$arIBlockInfo['INFO'].' '.Loc::getMessage("CAT_DEL_CATALOG2").".<br />"; } else { $boolCatalogUpdate = true; } } elseif ($arIBlockInfo['CATALOG']=="Y" || $arIBlockInfo['SUBSCRIPTION']=="Y" || 0 < $arIBlockInfo['PRODUCT_IBLOCK_ID']) { $boolAttr = $obCatalog->Add(array( 'IBLOCK_ID' => $arIBlockInfo['ID'], 'YANDEX_EXPORT' => $arIBlockInfo['YANDEX_EXPORT'], 'SUBSCRIPTION' => $arIBlockInfo['SUBSCRIPTION'], 'VAT_ID' => $arIBlockInfo['VAT_ID'], 'PRODUCT_IBLOCK_ID' => $arIBlockInfo['PRODUCT_IBLOCK_ID'], 'SKU_PROPERTY_ID' => $arIBlockInfo['SKU_PROPERTY_ID'] )); if (!$boolAttr) { $ex = $APPLICATION->GetException(); $strError = $ex->GetString(); $strWarning .= str_replace( array('#PRODUCT#', '#ERROR#'), array($arIBlockInfo['INFO'], $strError), Loc::getMessage('CAT_IBLOCK_OFFERS_ERR_CAT_ADD') ).'<br />'; $strWarning .= Loc::getMessage( 'CAT_IBLOCK_OFFERS_ERR_CAT_ADD', array(
function cmlStartElement($parser, $name, $attrs) { global $DB; global $USER; global $currentCatalog, $currentProduct, $currentProperty, $currentOffersList, $currentOffer; global $arIBlockCache, $iBlockIDString, $arCMLCurrencies; global $APPLICATION, $nameUTF, $IBLOCK_TYPE_ID, $strImportErrorMessage; global $oIBlock, $cmlLoadCnts; global $USE_TRANSLIT, $ADD_TRANSLIT; global $boolIBlockTranslit, $boolTranslitElement, $boolTranslitSection, $arTranslitElement, $arTranslitSection; static $SITE_ID = false; if (false === $SITE_ID) { $SITE_ID = 'ru'; $dbSite = CSite::GetByID($SITE_ID); if (!$dbSite->Fetch()) { $dbSite = CSite::GetList($by = 'sort', $order = 'asc'); $arSite = $dbSite->Fetch(); $SITE_ID = $arSite['ID']; } } switch ($name) { case $nameUTF["Catalog"]: $currentCatalog = array(); if (in_array($nameUTF["ID"], array_keys($attrs))) { $currentCatalog["ID"] = $attrs[$nameUTF["ID"]]; } if (in_array($nameUTF["Name"], array_keys($attrs))) { $currentCatalog["Name"] = $attrs[$nameUTF["Name"]]; } if (in_array($nameUTF["Description"], array_keys($attrs))) { $currentCatalog["Description"] = $attrs[$nameUTF["Description"]]; } $boolVersion = true; $dbIBlockList = CIBlock::GetList(array(), array("=TYPE" => $IBLOCK_TYPE_ID, "=XML_ID" => $currentCatalog["ID"], 'MIN_PERMISSION' => 'W')); if ($arIBlock = $dbIBlockList->Fetch()) { $arIBlock['VERSION'] = intval($arIBlock['VERSION']); if (1 != $arIBlock['VERSION']) { $bUpdate = true; $boolVersion = false; $res = false; } else { $bUpdate = true; $currentCatalog["BID"] = $arIBlock["ID"]; $res = $oIBlock->Update($currentCatalog["BID"], array("NAME" => $currentCatalog["Name"], "DESCRIPTION" => $currentCatalog["Description"])); } } elseif ($USER->IsAdmin()) { $bUpdate = false; $arFields = array("ACTIVE" => "Y", "NAME" => $currentCatalog["Name"], "XML_ID" => $currentCatalog["ID"], "IBLOCK_TYPE_ID" => $IBLOCK_TYPE_ID, "LID" => $SITE_ID, "WORKFLOW" => "N", "VERSION" => 1); if ('Y' == $USE_TRANSLIT && 'Y' == $ADD_TRANSLIT) { $arFields['FIELDS'] = array('CODE' => array('DEFAULT_VALUE' => array('TRANSLITERATION' => 'Y')), 'SECTION_CODE' => array('DEFAULT_VALUE' => array('TRANSLITERATION' => 'Y'))); } $currentCatalog["BID"] = $oIBlock->Add($arFields); $res = $currentCatalog["BID"] > 0; } else { $res = false; } $cmlLoadCnts["CATALOG"]++; if (!$res) { $strImportErrorMessage .= str_replace("#ERROR#", $boolVersion ? $oIBlock->LAST_ERROR : GetMessage('CML_R_VERSION'), str_replace("#NAME#", "[" . $currentCatalog["BID"] . "] \"" . $currentCatalog["Name"] . "\" (" . $currentCatalog["ID"] . ")", str_replace("#ACT#", $bUpdate ? GetMessage("CML_R_EDIT") : GetMessage("CML_R_ADD"), GetMessage("CML_R_IBLOCK")))) . ".<br>"; $currentCatalog = false; } else { $boolIBlockTranslit = $USE_TRANSLIT; $boolTranslitElement = false; $boolTranslitSection = false; $arTranslitElement = array(); $arTranslitSection = array(); if ('Y' == $boolIBlockTranslit) { $boolOutTranslit = false; $arIBlock = CIBlock::GetArrayByID($currentCatalog["BID"]); if (isset($arIBlock['FIELDS']['CODE']['DEFAULT_VALUE'])) { if ('Y' == $arIBlock['FIELDS']['CODE']['DEFAULT_VALUE']['TRANSLITERATION'] && 'Y' == $arIBlock['FIELDS']['CODE']['DEFAULT_VALUE']['USE_GOOGLE']) { $boolOutTranslit = true; } } if (isset($arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE'])) { if ('Y' == $arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE']['TRANSLITERATION'] && 'Y' == $arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE']['USE_GOOGLE']) { $boolOutTranslit = true; } } if ($boolOutTranslit) { $boolIBlockTranslit = 'N'; $strImportErrorMessage .= str_replace("#ERROR#", GetMessage('CATI_USE_CODE_TRANSLIT_OUT'), str_replace("#NAME#", "[" . $currentCatalog["BID"] . "] \"" . $currentCatalog["Name"] . "\" (" . $currentCatalog["ID"] . ")", str_replace("#ACT#", $bUpdate ? GetMessage("CML_R_EDIT") : GetMessage("CML_R_ADD"), GetMessage("CML_R_IBLOCK")))) . ".<br>"; $currentCatalog = false; break; } if ('Y' == $boolIBlockTranslit) { if (isset($arIBlock['FIELDS']['CODE']['DEFAULT_VALUE'])) { $arTransSettings = $arIBlock['FIELDS']['CODE']['DEFAULT_VALUE']; $boolTranslitElement = 'Y' == $arTransSettings['TRANSLITERATION'] ? true : false; $arTranslitElement = array("max_len" => $arTransSettings['TRANS_LEN'], "change_case" => $arTransSettings['TRANS_CASE'], "replace_space" => $arTransSettings['TRANS_SPACE'], "replace_other" => $arTransSettings['TRANS_OTHER'], "delete_repeat_replace" => 'Y' == $arTransSettings['TRANS_EAT'] ? true : false, "use_google" => 'Y' == $arTransSettings['USE_GOOGLE'] ? true : false); } if (isset($arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE'])) { $arTransSettings = $arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE']; $boolTranslitSection = 'Y' == $arTransSettings['TRANSLITERATION'] ? true : false; $arTranslitSection = array("max_len" => $arTransSettings['TRANS_LEN'], "change_case" => $arTransSettings['TRANS_CASE'], "replace_space" => $arTransSettings['TRANS_SPACE'], "replace_other" => $arTransSettings['TRANS_OTHER'], "delete_repeat_replace" => 'Y' == $arTransSettings['TRANS_EAT'] ? true : false, "use_google" => 'Y' == $arTransSettings['USE_GOOGLE'] ? true : false); } } } $arIBlockCache[$currentCatalog["ID"]] = IntVal($currentCatalog["BID"]); $iBlockIDString .= "," . IntVal($currentCatalog["BID"]); if (!CCatalog::GetByID($currentCatalog["BID"])) { CCatalog::Add(array("IBLOCK_ID" => $currentCatalog["BID"])); } if (function_exists("catalog_1c_mutator_catalogT")) { catalog_1c_mutator_catalogT($currentCatalog["BID"], $bUpdate, $attrs); } } break; case $nameUTF["Property"]: if ($currentCatalog) { $currentProperty = array(); $currentProperty["ID"] = $attrs[$nameUTF["ID"]]; $currentProperty["DataType"] = $attrs[$nameUTF["DataType"]]; $currentProperty["Multiple"] = $attrs[$nameUTF["Multiple"]] == "1" || $attrs[$nameUTF["Multiple"]] == "Y" ? "Y" : "N"; $currentProperty["Name"] = $attrs[$nameUTF["Name"]]; $currentProperty["DefaultValue"] = $attrs[$nameUTF["DefaultValue"]]; if ($currentProperty["DataType"] == "enumeration") { $currentProperty["DataType"] = "L"; } else { $currentProperty["DataType"] = "S"; } $strSql = "INSERT INTO b_catalog_cml_property (XML_ID, CATALOG_ID, DATA_TYPE, MULTIPLE, NAME, DEFAULT_VALUE) " . "VALUES ('" . $currentProperty["ID"] . "', " . $currentCatalog["BID"] . ", '" . $currentProperty["DataType"] . "', '" . $currentProperty["Multiple"] . "', '" . $DB->ForSql($currentProperty["Name"]) . "', '" . $DB->ForSql($currentProperty["DefaultValue"]) . "')"; $DB->Query($strSql); $cmlLoadCnts["PROPERTY"]++; } break; case $nameUTF["PropertyVariant"]: if ($currentProperty) { $currentPropertyEnum = array(); $currentPropertyEnum["ID"] = $attrs[$nameUTF["ID"]]; $currentPropertyEnum["Name"] = $attrs[$nameUTF["Name"]]; $currentPropertyEnum["Default"] = $currentProperty["DefaultValue"] == $currentPropertyEnum["ID"] ? "Y" : "N"; $strSql = "INSERT INTO b_catalog_cml_property_var (XML_ID, CATALOG_ID, PROPERTY_XML_ID, NAME, DEFAULT_VALUE) " . "VALUES ('" . $currentPropertyEnum["ID"] . "', " . $currentCatalog["BID"] . ", '" . $currentProperty["ID"] . "', '" . $DB->ForSql($currentPropertyEnum["Name"]) . "', '" . $currentPropertyEnum["Default"] . "')"; $DB->Query($strSql); } break; case $nameUTF["Category"]: if ($currentCatalog) { $currentCategory = array(); if (in_array($nameUTF["ID"], array_keys($attrs))) { $currentCategory["ID"] = $attrs[$nameUTF["ID"]]; } if (in_array($nameUTF["Name"], array_keys($attrs))) { $currentCategory["Name"] = $attrs[$nameUTF["Name"]]; } if (in_array($nameUTF["ParentCategory"], array_keys($attrs))) { $currentCategory["ParentCategory"] = $attrs[$nameUTF["ParentCategory"]]; } $currentCategory["Code"] = false; if (true === $boolTranslitSection) { $currentCategory["Code"] = CUtil::translit($currentCategory["Name"], 'ru', $arTranslitSection); } $strSql = "INSERT INTO b_catalog_cml_section (XML_ID, CATALOG_ID, PARENT_XML_ID, NAME, CODE) " . "VALUES ('" . $currentCategory["ID"] . "', " . $currentCatalog["BID"] . ", '" . $currentCategory["ParentCategory"] . "', '" . $DB->ForSql($currentCategory["Name"]) . "', '" . (false === $currentCategory["Code"] ? '' : $DB->ForSql($currentCategory["Code"])) . "')"; $DB->Query($strSql); $cmlLoadCnts["SECTION"]++; } break; case $nameUTF["Product"]: if ($currentCatalog) { $currentProduct = array(); $currentProduct["ID"] = $attrs[$nameUTF["ID"]]; $currentProduct["Name"] = $attrs[$nameUTF["Name"]]; $currentProduct["ParentCategory"] = $attrs[$nameUTF["ParentCategory"]]; $currentProduct["Code"] = false; if (true === $boolTranslitElement) { $currentProduct["Code"] = CUtil::translit($currentProduct["Name"], 'ru', $arTranslitElement); } $strSql = "INSERT INTO b_catalog_cml_product (XML_ID, CATALOG_ID, NAME, MODIFIED_BY, PARENT_CATEGORY, CODE) " . "VALUES ('" . $currentProduct["ID"] . "', " . $currentCatalog["BID"] . ", '" . $DB->ForSql($currentProduct["Name"]) . "', " . (IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : 1) . ", '" . $currentProduct["ParentCategory"] . "', '" . (false === $currentProduct["Code"] ? '' : $DB->ForSql($currentProduct["Code"])) . "')"; $DB->Query($strSql); if (function_exists("catalog_1c_mutator_productT")) { catalog_1c_mutator_productT($attrs); } $cmlLoadCnts["PRODUCT"]++; if (strlen($currentProduct["ParentCategory"]) > 0) { $strSql = "INSERT INTO b_catalog_cml_product_cat (CATALOG_ID, PRODUCT_XML_ID, CATEGORY_XML_ID) " . "VALUES (" . $currentCatalog["BID"] . ", '" . $currentProduct["ID"] . "', '" . $currentProduct["ParentCategory"] . "')"; $DB->Query($strSql); } } break; case $nameUTF["CategoryReference"]: if ($currentProduct) { $strSql = "INSERT INTO b_catalog_cml_product_cat (CATALOG_ID, PRODUCT_XML_ID, CATEGORY_XML_ID) " . "VALUES (" . $currentCatalog["BID"] . ", '" . $currentProduct["ID"] . "', '" . $attrs[$nameUTF["IdInCatalog"]] . "')"; $DB->Query($strSql); } break; case $nameUTF["PropertyValue"]: if ($currentProduct) { $propertyID = $attrs[$nameUTF["PropertyId"]]; $propertyValue = $attrs[$nameUTF["Value"]]; $strSql = "INSERT INTO b_catalog_cml_product_prop (CATALOG_ID, PRODUCT_XML_ID, PROPERTY_XML_ID, PROPERTY_VALUE, PROPERTY_VALUE_TEXT) " . "VALUES (" . $currentCatalog["BID"] . ", '" . $currentProduct["ID"] . "', '" . $propertyID . "', '" . $DB->ForSql($propertyValue, 255) . "', '" . $DB->ForSql($propertyValue) . "')"; $DB->Query($strSql); } elseif ($currentOffersList && !$currentOffer) { $priceType = $attrs[$nameUTF["Value"]]; $currentOffersList["PRICE_TYPE"] = $priceType; $strSql = "INSERT INTO b_catalog_cml_oflist_prop (OFFER_LIST_XML_ID, PROPERTY_VALUE) " . "VALUES (" . $currentOffersList["ID"] . ", '" . $DB->ForSql($priceType, 255) . "')"; $DB->Query($strSql); } break; case $nameUTF["OffersList"]: $currentOffersList = array(); $currentOffersList["CatalogID"] = $attrs[$nameUTF["CatalogID"]]; $currentOffersList["Currency"] = $arCMLCurrencies[$attrs[$nameUTF["Currency"]]]; if (strlen($currentOffersList["Currency"]) <= 0) { $currentOffersList["Currency"] = "USD"; } if (!array_key_exists($currentOffersList["CatalogID"], $arIBlockCache)) { $dbIBlockList = CIBlock::GetList(array(), array("XML_ID" => $currentOffersList["CatalogID"])); if ($arIBlock = $dbIBlockList->Fetch()) { $arIBlockCache[$currentOffersList["CatalogID"]] = IntVal($arIBlock["ID"]); } } $strSql = "INSERT INTO b_catalog_cml_oflist(CATALOG_ID) " . "VALUES (" . $arIBlockCache[$currentOffersList["CatalogID"]] . ")"; $DB->Query($strSql); $currentOffersList["ID"] = IntVal($DB->LastID()); break; case $nameUTF["Offer"]: if ($currentOffersList) { $currentOffer = array(); $currentOffer["ProductId"] = $attrs[$nameUTF["ProductId"]]; $currentOffer["Price"] = DoubleVal(str_replace(",", ".", $attrs[$nameUTF["Price"]])); $currentOffer["Amount"] = IntVal($attrs[$nameUTF["Amount"]]); $currentOffer["Currency"] = $arCMLCurrencies[$attrs[$nameUTF["Currency"]]]; if (strlen($currentOffer["Currency"]) <= 0) { $currentOffer["Currency"] = $currentOffersList["Currency"]; } $strSql = "INSERT INTO b_catalog_cml_offer (OFFER_LIST_XML_ID, PRODUCT_XML_ID, PRICE, AMOUNT, CURRENCY) " . "VALUES ('" . $currentOffersList["ID"] . "', '" . $currentOffer["ProductId"] . "', " . $currentOffer["Price"] . ", " . $currentOffer["Amount"] . ", '" . $currentOffer["Currency"] . "')"; $DB->Query($strSql); $cmlLoadCnts["OFFER"]++; } break; case $nameUTF['CommerceInfo']: if (isset($attrs[$nameUTF['CommerceInfoVersion']])) { $strVersion = (string) $attrs[$nameUTF['CommerceInfoVersion']]; if (version_compare($strVersion, '2.0') >= 0) { $strImportErrorMessage .= GetMessage("CICML_INVALID_VERSION") . "<br>"; } $currentCatalog = false; return false; } break; default: break; } return true; }
function ImportElementPrices($arXMLElement, &$counter, $arParent = false) { /** @global CMain $APPLICATION */ global $APPLICATION; static $catalogs = array(); $arElement = array("ID" => 0, "XML_ID" => $arXMLElement[$this->mess["IBLOCK_XML2_ID"]]); $hashPosition = strrpos($arElement["XML_ID"], "#"); if ($this->use_offers && $hashPosition === false && !$this->force_offers && isset($this->PROPERTY_MAP["CML2_LINK"]) && isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]])) { $IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"]; if (!isset($catalogs[$IBLOCK_ID])) { $catalogs[$IBLOCK_ID] = true; $rs = CCatalog::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID)); if (!$rs->Fetch()) { $obCatalog = new CCatalog(); $boolFlag = $obCatalog->Add(array("IBLOCK_ID" => $IBLOCK_ID, "YANDEX_EXPORT" => "N", "SUBSCRIPTION" => "N")); if (!$boolFlag) { if ($ex = $APPLICATION->GetException()) { $this->LAST_ERROR = $ex->GetString(); } return 0; } } } } else { $IBLOCK_ID = $this->next_step["IBLOCK_ID"]; } $obElement = new CIBlockElement(); $rsElement = $obElement->GetList(array("ID" => "asc"), array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID), false, false, array("ID", "TMP_ID", "ACTIVE")); $arDBElement = $rsElement->Fetch(); if ($arDBElement) { $arElement["ID"] = $arDBElement["ID"]; } if (isset($arXMLElement[$this->mess["IBLOCK_XML2_STORE_AMOUNT_LIST"]])) { $arElement["STORE_AMOUNT"] = array(); foreach ($arXMLElement[$this->mess["IBLOCK_XML2_STORE_AMOUNT_LIST"]] as $storeAmount) { if (isset($storeAmount[$this->mess["IBLOCK_XML2_STORE_ID"]])) { $storeXMLID = $storeAmount[$this->mess["IBLOCK_XML2_STORE_ID"]]; $amount = $this->ToFloat($storeAmount[$this->mess["IBLOCK_XML2_AMOUNT"]]); $arElement["STORE_AMOUNT"][$storeXMLID] = $amount; } } } elseif (isset($arXMLElement[$this->mess["IBLOCK_XML2_RESTS"]])) { $arElement["STORE_AMOUNT"] = array(); foreach ($arXMLElement[$this->mess["IBLOCK_XML2_RESTS"]] as $xmlRest) { foreach ($xmlRest as $storeAmount) { if (is_array($storeAmount)) { if (isset($storeAmount[$this->mess["IBLOCK_XML2_ID"]])) { $storeXMLID = $storeAmount[$this->mess["IBLOCK_XML2_ID"]]; $amount = $this->ToFloat($storeAmount[$this->mess["IBLOCK_XML2_AMOUNT"]]); $arElement["STORE_AMOUNT"][$storeXMLID] = $amount; } } else { if (strlen($storeAmount) > 0) { $amount = $this->ToFloat($storeAmount); $arElement["QUANTITY"] = $amount; } } } } } elseif ($arParent && (array_key_exists($this->mess["IBLOCK_XML2_STORES"], $arXMLElement) || array_key_exists($this->mess["IBLOCK_XML2_STORE"], $arXMLElement))) { $arElement["STORE_AMOUNT"] = array(); $rsStores = $this->_xml_file->GetList(array("ID" => "asc"), array("><LEFT_MARGIN" => array($arParent["LEFT_MARGIN"], $arParent["RIGHT_MARGIN"]), "NAME" => $this->mess["IBLOCK_XML2_STORE"]), array("ID", "ATTRIBUTES")); while ($arStore = $rsStores->Fetch()) { if (strlen($arStore["ATTRIBUTES"]) > 0) { $info = unserialize($arStore["ATTRIBUTES"]); if (is_array($info) && array_key_exists($this->mess["IBLOCK_XML2_STORE_ID"], $info) && array_key_exists($this->mess["IBLOCK_XML2_STORE_AMOUNT"], $info)) { $arElement["STORE_AMOUNT"][$info[$this->mess["IBLOCK_XML2_STORE_ID"]]] = $this->ToFloat($info[$this->mess["IBLOCK_XML2_STORE_AMOUNT"]]); } } } } if (isset($arElement["STORE_AMOUNT"])) { $this->ImportStoresAmount($arElement["STORE_AMOUNT"], $arElement["ID"], $counter); } if ($arDBElement) { $arProduct = array("ID" => $arElement["ID"]); if (isset($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]])) { $arElement["PRICES"] = array(); foreach ($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]] as $price) { if (isset($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]) && array_key_exists($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]], $this->PRICES_MAP)) { $price["PRICE"] = $this->PRICES_MAP[$price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]]; $arElement["PRICES"][] = $price; if (array_key_exists($this->mess["IBLOCK_XML2_MEASURE"], $price) && !isset($arProduct["MEASURE"])) { $tmp = $this->convertBaseUnitFromXmlToPropertyValue($price[$this->mess["IBLOCK_XML2_MEASURE"]]); if ($tmp["DESCRIPTION"] > 0) { $arProduct["MEASURE"] = $tmp["DESCRIPTION"]; } } } } $arElement["DISCOUNTS"] = array(); if (isset($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]])) { foreach ($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]] as $discount) { if (isset($discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]]) && $discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]] === $this->mess["IBLOCK_XML2_DISCOUNT_COND_VOLUME"]) { $discount_value = $this->ToInt($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_VALUE"]]); $discount_percent = $this->ToFloat($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_PERCENT"]]); if ($discount_value > 0 && $discount_percent > 0) { $arElement["DISCOUNTS"][$discount_value] = $discount_percent; } } } } } if (array_key_exists($this->mess["IBLOCK_XML2_AMOUNT"], $arXMLElement)) { $arElementTmp = array(); $arElement["QUANTITY_RESERVED"] = 0; if ($arElement["ID"]) { $arElementTmp = CCatalogProduct::GetById($arElement["ID"]); } if (is_array($arElementTmp) && !empty($arElementTmp) && isset($arElementTmp["QUANTITY_RESERVED"])) { $arElement["QUANTITY_RESERVED"] = $arElementTmp["QUANTITY_RESERVED"]; } $arElement["QUANTITY"] = $this->ToFloat($arXMLElement[$this->mess["IBLOCK_XML2_AMOUNT"]]) - doubleval($arElement["QUANTITY_RESERVED"]); } if (isset($arElement["PRICES"]) && $this->bCatalog) { if (isset($arElement["QUANTITY"])) { $arProduct["QUANTITY"] = $arElement["QUANTITY"]; } elseif (isset($arElement["STORE_AMOUNT"]) && !empty($arElement["STORE_AMOUNT"])) { $arProduct["QUANTITY"] = array_sum($arElement["STORE_AMOUNT"]); } $rsWeight = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array(), array("CODE" => "CML2_TRAITS")); while ($arWeight = $rsWeight->Fetch()) { if ($arWeight["DESCRIPTION"] == $this->mess["IBLOCK_XML2_WEIGHT"]) { $arProduct["WEIGHT"] = $this->ToFloat($arWeight["VALUE"]) * 1000; } } $rsUnit = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array(), array("CODE" => "CML2_BASE_UNIT")); while ($arUnit = $rsUnit->Fetch()) { if ($arUnit["DESCRIPTION"] > 0) { $arProduct["MEASURE"] = $arUnit["DESCRIPTION"]; } } //Here start VAT handling //Check if all the taxes exists in BSM catalog $arTaxMap = array(); $rsTaxProperty = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array("sort" => "asc"), array("CODE" => "CML2_TAXES")); while ($arTaxProperty = $rsTaxProperty->Fetch()) { if (strlen($arTaxProperty["VALUE"]) > 0 && strlen($arTaxProperty["DESCRIPTION"]) > 0 && !array_key_exists($arTaxProperty["DESCRIPTION"], $arTaxMap)) { $arTaxMap[$arTaxProperty["DESCRIPTION"]] = array("RATE" => $this->ToFloat($arTaxProperty["VALUE"]), "ID" => $this->CheckTax($arTaxProperty["DESCRIPTION"], $this->ToFloat($arTaxProperty["VALUE"]))); } } //First find out if all the prices have TAX_IN_SUM true $TAX_IN_SUM = "Y"; foreach ($arElement["PRICES"] as $price) { if ($price["PRICE"]["TAX_IN_SUM"] !== "true") { $TAX_IN_SUM = "N"; break; } } //If there was found not included tax we'll make sure //that all prices has the same flag if ($TAX_IN_SUM === "N") { foreach ($arElement["PRICES"] as $price) { if ($price["PRICE"]["TAX_IN_SUM"] !== "false") { $TAX_IN_SUM = "Y"; break; } } //Check if there is a mix of tax in sum //and correct it by recalculating all the prices if ($TAX_IN_SUM === "Y") { foreach ($arElement["PRICES"] as $key => $price) { if ($price["PRICE"]["TAX_IN_SUM"] !== "true") { $TAX_NAME = $price["PRICE"]["TAX_NAME"]; if (array_key_exists($TAX_NAME, $arTaxMap)) { $PRICE_WO_TAX = $this->ToFloat($price[$this->mess["IBLOCK_XML2_PRICE_FOR_ONE"]]); $PRICE = $PRICE_WO_TAX + $PRICE_WO_TAX / 100.0 * $arTaxMap[$TAX_NAME]["RATE"]; $arElement["PRICES"][$key][$this->mess["IBLOCK_XML2_PRICE_FOR_ONE"]] = $PRICE; } } } } } if ($TAX_IN_SUM == "Y" && $arTaxMap) { $vat = current($arTaxMap); $arProduct["VAT_ID"] = $vat["ID"]; } else { foreach ($arElement["PRICES"] as $price) { $TAX_NAME = $price["PRICE"]["TAX_NAME"]; if (array_key_exists($TAX_NAME, $arTaxMap)) { $arProduct["VAT_ID"] = $arTaxMap[$TAX_NAME]["ID"]; break; } } } $arProduct["VAT_INCLUDED"] = $TAX_IN_SUM; CCatalogProduct::Add($arProduct); $this->SetProductPrice($arElement["ID"], $arElement["PRICES"], $arElement["DISCOUNTS"]); } elseif ($this->bCatalog && isset($arElement["STORE_AMOUNT"]) && !empty($arElement["STORE_AMOUNT"]) && CCatalogProduct::GetById($arElement["ID"])) { CCatalogProduct::Update($arElement["ID"], array("QUANTITY" => array_sum($arElement["STORE_AMOUNT"]))); } elseif ($this->bCatalog && isset($arElement["QUANTITY"]) && CCatalogProduct::GetById($arElement["ID"])) { CCatalogProduct::Update($arElement["ID"], array("QUANTITY" => $arElement["QUANTITY"])); } } $counter["UPD"]++; return $arElement["ID"]; }
"replace_space" => $arTransSettings['TRANS_SPACE'], "replace_other" => $arTransSettings['TRANS_OTHER'], "delete_repeat_replace" => ('Y' == $arTransSettings['TRANS_EAT'] ? true : false), "use_google" => ('Y' == $arTransSettings['USE_GOOGLE'] ? true : false), ); } } } if ($bNewRecord_tmp) $STT_CATALOG_ADD++; else $STT_CATALOG_UPDATE++; $arCatalogs[$IBLOCK_XML_ID] = $IBLOCK_ID; if(!CCatalog::GetByID($IBLOCK_ID)) CCatalog::Add(Array("IBLOCK_ID"=>$IBLOCK_ID)); $arProperties = array(); $ibp = new CIBlockProperty(); $props = $xCatNode->select_nodes("/".$nameUTF['Property']); for($j=0, $intPropCount = count($props); $j<$intPropCount; $j++) { $xPropNode = $props[$j]; $PROP_XML_ID = $xPropNode->GetAttribute($nameUTF['ID']); $PROP_TYPE = $xPropNode->GetAttribute($nameUTF['DataType']); $PROP_MULTIPLE = ($xPropNode->GetAttribute($nameUTF['Multiple'])=="1"?"Y":"N"); $PROP_NAME = $xPropNode->GetAttribute($nameUTF['Name']); $PROP_DEF = $xPropNode->GetAttribute($nameUTF['DefaultValue']);
function ImportElementPrices($arXMLElement, &$counter) { /** @global CMain $APPLICATION */ global $APPLICATION; static $catalogs = array(); $arElement = array( "ID" => 0, "XML_ID" => $arXMLElement[GetMessage("IBLOCK_XML2_ID")], ); $hashPosition = strrpos($arElement["XML_ID"], "#"); if ( $this->use_offers && $hashPosition === false && isset($this->PROPERTY_MAP["CML2_LINK"]) && isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]) ) { $IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"]; if (!isset($catalogs[$IBLOCK_ID])) { $catalogs[$IBLOCK_ID] = true; $rs = CCatalog::GetList(array(),array("IBLOCK_ID" => $IBLOCK_ID)); if (!$rs->Fetch()) { $obCatalog = new CCatalog(); $boolFlag = $obCatalog->Add(array( "IBLOCK_ID" => $IBLOCK_ID, "YANDEX_EXPORT" => "N", "SUBSCRIPTION" => "N", )); if (!$boolFlag) { if ($ex = $APPLICATION->GetException()) $this->LAST_ERROR = $ex->GetString(); return 0; } } } } else { $IBLOCK_ID = $this->next_step["IBLOCK_ID"]; } $obElement = new CIBlockElement; $rsElement = $obElement->GetList( Array("ID"=>"asc"), Array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID), false, false, Array("ID", "TMP_ID", "ACTIVE") ); if($arDBElement = $rsElement->Fetch()) { $arElement["ID"] = $arDBElement["ID"]; if(isset($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")])) {//Collect price information for future use $arElement["PRICES"] = array(); foreach($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")] as $price) { if( isset($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]) && array_key_exists($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")], $this->PRICES_MAP) ) { $price["PRICE"] = $this->PRICES_MAP[$price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]]; $arElement["PRICES"][] = $price; } } $arElement["DISCOUNTS"] = array(); if(isset($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")])) { foreach($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")] as $discount) { if( isset($discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")]) && $discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")] === GetMessage("IBLOCK_XML2_DISCOUNT_COND_VOLUME") ) { $discount_value = $this->ToInt($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_VALUE")]); $discount_percent = $this->ToFloat($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_PERCENT")]); if($discount_value > 0 && $discount_percent > 0) $arElement["DISCOUNTS"][$discount_value] = $discount_percent; } } } } if(isset($arXMLElement[GetMessage("IBLOCK_XML2_AMOUNT")])) { $arElementTmp = array(); $arElement["QUANTITY_RESERVED"] = 0; if($arElement["ID"]) $arElementTmp = CCatalogProduct::GetById($arElement["ID"]); if(is_array($arElementTmp) && !empty($arElementTmp) && isset($arElementTmp["QUANTITY_RESERVED"])) $arElement["QUANTITY_RESERVED"] = $arElementTmp["QUANTITY_RESERVED"]; $arElement["QUANTITY"] = $this->ToFloat($arXMLElement[GetMessage("IBLOCK_XML2_AMOUNT")]) - doubleval($arElement["QUANTITY_RESERVED"]); } else $arElement["QUANTITY"] = 0; if(isset($arElement["PRICES"]) && $this->bCatalog) { $arProduct = array( "ID" => $arElement["ID"], ); if(isset($arElement["QUANTITY"])) $arProduct["QUANTITY"] = $arElement["QUANTITY"]; //Get weight from element traits $rsWeight = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array(), array("CODE" => "CML2_TRAITS")); while($arWeight = $rsWeight->Fetch()) { if($arWeight["DESCRIPTION"] == GetMessage("IBLOCK_XML2_WEIGHT")) $arProduct["WEIGHT"] = $this->ToFloat($arWeight["VALUE"])*1000; } //Here start VAT handling //Check if all the taxes exists in BSM catalog $arTaxMap = array(); $rsTaxProperty = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array("sort" => "asc"), array("CODE" => "CML2_TAXES")); while($arTaxProperty = $rsTaxProperty->Fetch()) { if( strlen($arTaxProperty["VALUE"]) > 0 && strlen($arTaxProperty["DESCRIPTION"]) > 0 && !array_key_exists($arTaxProperty["DESCRIPTION"], $arTaxMap) ) { $arTaxMap[$arTaxProperty["DESCRIPTION"]] = array( "RATE" => $this->ToFloat($arTaxProperty["VALUE"]), "ID" => $this->CheckTax($arTaxProperty["DESCRIPTION"], $this->ToFloat($arTaxProperty["VALUE"])), ); } } //First find out if all the prices have TAX_IN_SUM true $TAX_IN_SUM = "Y"; foreach($arElement["PRICES"] as $price) { if($price["PRICE"]["TAX_IN_SUM"] !== "true") { $TAX_IN_SUM = "N"; break; } } //If there was found not included tax we'll make sure //that all prices has the same flag if($TAX_IN_SUM === "N") { foreach($arElement["PRICES"] as $price) { if($price["PRICE"]["TAX_IN_SUM"] !== "false") { $TAX_IN_SUM = "Y"; break; } } //Check if there is a mix of tax in sum //and correct it by recalculating all the prices if($TAX_IN_SUM === "Y") { foreach($arElement["PRICES"] as $key=>$price) { if($price["PRICE"]["TAX_IN_SUM"] !== "true") { $TAX_NAME = $price["PRICE"]["TAX_NAME"]; if(array_key_exists($TAX_NAME, $arTaxMap)) { $PRICE_WO_TAX = $this->ToFloat($price[GetMessage("IBLOCK_XML2_PRICE_FOR_ONE")]); $PRICE = $PRICE_WO_TAX + ($PRICE_WO_TAX / 100.0 * $arTaxMap[$TAX_NAME]["RATE"]); $arElement["PRICES"][$key][GetMessage("IBLOCK_XML2_PRICE_FOR_ONE")] = $PRICE; } } } } } foreach($arElement["PRICES"] as $price) { $TAX_NAME = $price["PRICE"]["TAX_NAME"]; if(array_key_exists($TAX_NAME, $arTaxMap)) { $arProduct["VAT_ID"] = $arTaxMap[$TAX_NAME]["ID"]; break; } } $arProduct["VAT_INCLUDED"] = $TAX_IN_SUM; CCatalogProduct::Add($arProduct); $this->SetProductPrice($arElement["ID"], $arElement["PRICES"], $arElement["DISCOUNTS"]); $counter["UPD"]++; } } if(isset($arXMLElement[GetMessage("IBLOCK_XML2_STORE_AMOUNT_LIST")])) { $arElement["STORE_AMOUNT"]=array(); foreach($arXMLElement[GetMessage("IBLOCK_XML2_STORE_AMOUNT_LIST")] as $storeAmount) { if(isset($storeAmount[GetMessage("IBLOCK_XML2_STORE_ID")])) { $storeXMLID = $storeAmount[GetMessage("IBLOCK_XML2_STORE_ID")]; $amount = $storeAmount[GetMessage("IBLOCK_XML2_AMOUNT")]; $arElement["STORE_AMOUNT"][]=array($storeXMLID => $amount); } } } if(isset($arElement["STORE_AMOUNT"])) $this->ImportStoresAmount($arElement["STORE_AMOUNT"], $arElement["ID"], $counter); return $arElement["ID"]; }
public static function Add($arFields) { if (!CModule::IncludeModule('catalog')) { return false; } self::$LAST_ERROR = ''; global $DB; $tableName = CCrmCatalog::TABLE_NAME; if (!self::CheckFields('ADD', $arFields, 0)) { return false; } $DB->Add($tableName, $arFields, array(), '', false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__); if (strlen($DB->db_Error) > 0) { self::RegisterError($DB->db_Error); return false; } // -------------- register in catalog module --------------> $catalogId = $arFields['ID']; $arFields = array('IBLOCK_ID' => $catalogId, 'CATALOG' => 'Y'); // get default vat $defCatVatId = 0; $dbVat = CCatalogVat::GetList(array('SORT' => 'ASC')); if ($arVat = $dbVat->Fetch()) { $defCatVatId = $arVat['ID']; unset($arVat); } unset($dbVat); $defCatVatId = intval($defCatVatId); if ($defCatVatId > 0) { $arFields['VAT_ID'] = $defCatVatId; } // add crm iblock to catalog $CCatalog = new CCatalog(); $dbRes = $CCatalog->GetList(array(), array('ID' => $catalogId), false, false, array('ID')); if (!$dbRes->Fetch()) { if ($CCatalog->Add($arFields)) { COption::SetOptionString('catalog', 'save_product_without_price', 'Y'); COption::SetOptionString('catalog', 'default_can_buy_zero', 'Y'); } else { self::RegisterError(GetMessage('CRM_ERR_REGISTER_CATALOG')); return false; } } // <------------- register in catalog module -------------- return true; }
function ImportMetaData($xml_root_id, $IBLOCK_TYPE, $IBLOCK_LID, $bUpdateIBlock = true) { global $DB; $rs = $this->_xml_file->GetList(array(), array("ID" => $xml_root_id, "NAME" => GetMessage("IBLOCK_XML2_COMMERCE_INFO")), array("ID", "ATTRIBUTES")); $ar = $rs->Fetch(); if ($ar && strlen($ar["ATTRIBUTES"]) > 0) { $info = unserialize($ar["ATTRIBUTES"]); if (is_array($info) && array_key_exists(GetMessage("IBLOCK_XML2_SUM_FORMAT"), $info)) { if (preg_match("#" . GetMessage("IBLOCK_XML2_SUM_FORMAT_DELIM") . "=(.);{0,1}#", $info[GetMessage("IBLOCK_XML2_SUM_FORMAT")], $match)) { $this->next_step["sdp"] = $match[1]; } } } $meta_data_xml_id = false; $XML_ELEMENTS_PARENT = false; $XML_SECTIONS_PARENT = false; $XML_PROPERTIES_PARENT = false; $XML_SECTIONS_PROPERTIES_PARENT = false; $XML_PRICES_PARENT = false; $XML_STORES_PARENT = false; $XML_SECTION_PROPERTIES = false; $this->next_step["bOffer"] = false; $rs = $this->_xml_file->GetList(array(), array("PARENT_ID" => $xml_root_id, "NAME" => GetMessage("IBLOCK_XML2_CATALOG")), array("ID", "ATTRIBUTES")); $ar = $rs->Fetch(); if (!$ar) { $rs = $this->_xml_file->GetList(array(), array("PARENT_ID" => $xml_root_id, "NAME" => GetMessage("IBLOCK_XML2_OFFER_LIST")), array("ID", "ATTRIBUTES")); $ar = $rs->Fetch(); $this->next_step["bOffer"] = true; } if ($ar) { if (strlen($ar["ATTRIBUTES"]) > 0) { $attrs = unserialize($ar["ATTRIBUTES"]); if (is_array($attrs)) { if (array_key_exists(GetMessage("IBLOCK_XML2_UPDATE_ONLY"), $attrs)) { $this->next_step["bUpdateOnly"] = $attrs[GetMessage("IBLOCK_XML2_UPDATE_ONLY")] == "true" || intval($attrs["IBLOCK_XML2_UPDATE_ONLY"]) ? true : false; } } } //Information block fields with following Add/Update $arIBlock = array(); $rs = $this->_xml_file->GetList(array("ID" => "asc"), array("PARENT_ID" => $ar["ID"])); while ($ar = $rs->Fetch()) { if (isset($ar["VALUE_CLOB"])) { $ar["VALUE"] = $ar["VALUE_CLOB"]; } if ($ar["NAME"] == GetMessage("IBLOCK_XML2_ID")) { $arIBlock["XML_ID"] = ($this->use_iblock_type_id ? $IBLOCK_TYPE . "-" : "") . $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_CATALOG_ID")) { $arIBlock["CATALOG_XML_ID"] = ($this->use_iblock_type_id ? $IBLOCK_TYPE . "-" : "") . $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_NAME")) { $arIBlock["NAME"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_DESCRIPTION")) { $arIBlock["DESCRIPTION"] = $ar["VALUE"]; $arIBlock["DESCRIPTION_TYPE"] = "html"; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_POSITIONS") || $ar["NAME"] == GetMessage("IBLOCK_XML2_OFFERS")) { $XML_ELEMENTS_PARENT = $ar["ID"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_PRICE_TYPES")) { $XML_PRICES_PARENT = $ar["ID"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_STORES")) { $XML_STORES_PARENT = $ar["ID"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_METADATA_ID")) { $meta_data_xml_id = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_UPDATE_ONLY")) { $this->next_step["bUpdateOnly"] = $ar["VALUE"] == "true" || intval($ar["VALUE"]) ? true : false; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_CODE")) { $arIBlock["CODE"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_SORT")) { $arIBlock["SORT"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_LIST_URL")) { $arIBlock["LIST_PAGE_URL"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_DETAIL_URL")) { $arIBlock["DETAIL_PAGE_URL"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_SECTION_URL")) { $arIBlock["SECTION_PAGE_URL"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_INDEX_ELEMENTS")) { $arIBlock["INDEX_ELEMENT"] = $ar["VALUE"] == "true" || intval($ar["VALUE"]) ? "Y" : "N"; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_INDEX_SECTIONS")) { $arIBlock["INDEX_SECTION"] = $ar["VALUE"] == "true" || intval($ar["VALUE"]) ? "Y" : "N"; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_SECTIONS_NAME")) { $arIBlock["SECTIONS_NAME"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_SECTION_NAME")) { $arIBlock["SECTION_NAME"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_ELEMENTS_NAME")) { $arIBlock["ELEMENTS_NAME"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_ELEMENT_NAME")) { $arIBlock["ELEMENT_NAME"] = $ar["VALUE"]; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_PICTURE")) { if (strlen($ar["VALUE"]) > 0) { $arIBlock["PICTURE"] = $this->MakeFileArray($ar["VALUE"]); } else { $arIBlock["PICTURE"] = $this->MakeFileArray($this->_xml_file->GetAllChildrenArray($ar["ID"])); } } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_BX_WORKFLOW")) { $arIBlock["WORKFLOW"] = $ar["VALUE"] == "true" || intval($ar["VALUE"]) ? "Y" : "N"; } elseif ($ar["NAME"] == GetMessage("IBLOCK_XML2_LABELS")) { $arLabels = $this->_xml_file->GetAllChildrenArray($ar["ID"]); foreach ($arLabels as $key => $arLabel) { $id = $arLabel[GetMessage("IBLOCK_XML2_ID")]; $label = $arLabel[GetMessage("IBLOCK_XML2_VALUE")]; if (strlen($id) > 0 && strlen($label) > 0) { $arIBlock[$id] = $label; } } } } if ($this->next_step["bOffer"] && !$this->use_offers) { if (strlen($arIBlock["CATALOG_XML_ID"]) > 0) { $arIBlock["XML_ID"] = $arIBlock["CATALOG_XML_ID"]; $this->next_step["bUpdateOnly"] = true; } } $obIBlock = new CIBlock(); $rsIBlocks = $obIBlock->GetList(array(), array("XML_ID" => $arIBlock["XML_ID"])); $ar = $rsIBlocks->Fetch(); //Also check for non bitrix xml file if (!$ar && !array_key_exists("CODE", $arIBlock)) { if ($this->next_step["bOffer"] && $this->use_offers) { $rsIBlocks = $obIBlock->GetList(array(), array("XML_ID" => "FUTURE-1C-OFFERS")); } else { $rsIBlocks = $obIBlock->GetList(array(), array("XML_ID" => "FUTURE-1C-CATALOG")); } $ar = $rsIBlocks->Fetch(); } if ($ar) { if ($bUpdateIBlock && (!$this->next_step["bOffer"] || $this->use_offers)) { if ($obIBlock->Update($ar["ID"], $arIBlock)) { $arIBlock["ID"] = $ar["ID"]; } else { return $obIBlock->LAST_ERROR; } } else { $arIBlock["ID"] = $ar["ID"]; } } else { $arIBlock["IBLOCK_TYPE_ID"] = $this->CheckIBlockType($IBLOCK_TYPE); if (!$arIBlock["IBLOCK_TYPE_ID"]) { return GetMessage("IBLOCK_XML2_TYPE_ADD_ERROR"); } $arIBlock["GROUP_ID"] = array(2 => "R"); $arIBlock["LID"] = $this->CheckSites($IBLOCK_LID); $arIBlock["ACTIVE"] = "Y"; $arIBlock["WORKFLOW"] = "N"; $arIBlock["ID"] = $obIBlock->Add($arIBlock); if (!$arIBlock["ID"]) { return $obIBlock->LAST_ERROR; } } //Make this catalog if ($this->bCatalog && $this->next_step["bOffer"]) { $obCatalog = new CCatalog(); $intParentID = $this->GetIBlockByXML_ID($arIBlock["CATALOG_XML_ID"]); if (0 < intval($intParentID) && $this->use_offers) { /* $rs = CCatalog::GetList(array(),array("IBLOCK_ID"=>$arIBlock["ID"])); if($arOffer = $rs->Fetch()) { CCatalog::Update($arIBlock["ID"],array('OFFERS' => 'Y')); } else { CCatalog::Add(array("IBLOCK_ID"=>$arIBlock["ID"], "YANDEX_EXPORT"=>"N", "SUBSCRIPTION"=>"N",'OFFERS' => 'Y','OFFERS_IBLOCK_ID' => 0)); } $rs = CCatalog::GetList(array(),array('IBLOCK_ID' => $intParentID)); if ($arParent = $rs->Fetch()) { CCatalog::Update($arParent['ID'],array('OFFERS_IBLOCK_ID' => $arIBlock["ID"])); } else { CCatalog::Add(array("IBLOCK_ID"=>$intParentID, "YANDEX_EXPORT"=>"N", "SUBSCRIPTION"=>"N",'OFFERS' => 'N','OFFERS_IBLOCK_ID' => $arIBlock["ID"])); } */ $mxSKUProp = $obCatalog->LinkSKUIBlock($intParentID, $arIBlock["ID"]); if (!$mxSKUProp) { if ($ex = $APPLICATION->GetException()) { $result = $ex->GetString(); return $result; } } else { $boolFlag = true; $rs = CCatalog::GetList(array(), array("IBLOCK_ID" => $arIBlock["ID"])); if ($arOffer = $rs->Fetch()) { $boolFlag = $obCatalog->Update($arIBlock["ID"], array('PRODUCT_IBLOCK_ID' => $intParentID, 'SKU_PROPERTY_ID' => $mxSKUProp)); } else { $boolFlag = $obCatalog->Add(array("IBLOCK_ID" => $arIBlock["ID"], "YANDEX_EXPORT" => "N", "SUBSCRIPTION" => "N", 'PRODUCT_IBLOCK_ID' => $intParentID, 'SKU_PROPERTY_ID' => $mxSKUProp)); } if (!$boolFlag) { if ($ex = $APPLICATION->GetException()) { $result = $ex->GetString(); return $result; } } } } else { $rs = CCatalog::GetList(array(), array("IBLOCK_ID" => $arIBlock["ID"])); if (!$rs->Fetch()) { $boolFlag = $obCatalog->Add(array("IBLOCK_ID" => $arIBlock["ID"], "YANDEX_EXPORT" => "N", "SUBSCRIPTION" => "N")); if (!$boolFlag) { if ($ex = $APPLICATION->GetException()) { $result = $ex->GetString(); return $result; } } } } } //For non bitrix xml file //Check for mandatory properties and add them as necessary if (!array_key_exists("CODE", $arIBlock)) { $arProperties = array("CML2_BAR_CODE" => GetMessage("IBLOCK_XML2_BAR_CODE"), "CML2_ARTICLE" => GetMessage("IBLOCK_XML2_ARTICLE"), "CML2_ATTRIBUTES" => array("NAME" => GetMessage("IBLOCK_XML2_ATTRIBUTES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1), "CML2_TRAITS" => array("NAME" => GetMessage("IBLOCK_XML2_TRAITS"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1), "CML2_BASE_UNIT" => GetMessage("IBLOCK_XML2_BASE_UNIT_NAME"), "CML2_TAXES" => array("NAME" => GetMessage("IBLOCK_XML2_TAXES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1), "CML2_PICTURES" => array("NAME" => GetMessage("IBLOCK_XML2_PICTURES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, "PROPERTY_TYPE" => "F", "CODE" => "MORE_PHOTO"), "CML2_FILES" => array("NAME" => GetMessage("IBLOCK_XML2_FILES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, "PROPERTY_TYPE" => "F", "CODE" => "FILES")); foreach ($arProperties as $k => $v) { $result = $this->CheckProperty($arIBlock["ID"], $k, $v); if ($result !== true) { return $result; } } //For offers make special property: link to catalog if (isset($arIBlock["CATALOG_XML_ID"]) && $this->use_offers) { $result = $this->CheckProperty($arIBlock["ID"], "CML2_LINK", array("NAME" => GetMessage("IBLOCK_XML2_CATALOG_ELEMENT"), "PROPERTY_TYPE" => "E", "USER_TYPE" => "SKU", "LINK_IBLOCK_ID" => $this->GetIBlockByXML_ID($arIBlock["CATALOG_XML_ID"]), "FILTRABLE" => "Y")); } } $this->next_step["IBLOCK_ID"] = $arIBlock["ID"]; $this->next_step["XML_ELEMENTS_PARENT"] = $XML_ELEMENTS_PARENT; } if ($meta_data_xml_id) { $rs = $this->_xml_file->GetList(array(), array("PARENT_ID" => $xml_root_id, "NAME" => GetMessage("IBLOCK_XML2_METADATA")), array("ID")); while ($arMetadata = $rs->Fetch()) { //Find referenced metadata $bMetaFound = false; $meta_roots = array(); $rsMetaRoots = $this->_xml_file->GetList(array("ID" => "asc"), array("PARENT_ID" => $arMetadata["ID"])); while ($arMeta = $rsMetaRoots->Fetch()) { if (isset($arMeta["VALUE_CLOB"])) { $arMeta["VALUE"] = $arMeta["VALUE_CLOB"]; } if ($arMeta["NAME"] == GetMessage("IBLOCK_XML2_ID") && $arMeta["VALUE"] == $meta_data_xml_id) { $bMetaFound = true; } $meta_roots[] = $arMeta; } //Get xml parents of the properties and sections if ($bMetaFound) { foreach ($meta_roots as $arMeta) { if ($arMeta["NAME"] == GetMessage("IBLOCK_XML2_GROUPS")) { $XML_SECTIONS_PARENT = $arMeta["ID"]; } elseif ($arMeta["NAME"] == GetMessage("IBLOCK_XML2_PROPERTIES")) { $XML_PROPERTIES_PARENT = $arMeta["ID"]; } elseif ($arMeta["NAME"] == GetMessage("IBLOCK_XML2_GROUPS_PROPERTIES")) { $XML_SECTIONS_PROPERTIES_PARENT = $arMeta["ID"]; } elseif ($arMeta["NAME"] == GetMessage("IBLOCK_XML2_SECTION_PROPERTIES")) { $XML_SECTION_PROPERTIES = $arMeta["ID"]; } } break; } } } if ($XML_PROPERTIES_PARENT) { $result = $this->ImportProperties($XML_PROPERTIES_PARENT, $arIBlock["ID"]); if ($result !== true) { return $result; } } if ($XML_SECTION_PROPERTIES) { $result = $this->ImportSectionProperties($XML_SECTION_PROPERTIES, $arIBlock["ID"]); if ($result !== true) { return $result; } } if ($XML_SECTIONS_PROPERTIES_PARENT) { $result = $this->ImportSectionsProperties($XML_SECTIONS_PROPERTIES_PARENT, $arIBlock["ID"]); if ($result !== true) { return $result; } } if ($XML_PRICES_PARENT) { if ($this->bCatalog) { $result = $this->ImportPrices($XML_PRICES_PARENT, $arIBlock["ID"], $IBLOCK_LID); if ($result !== true) { return $result; } } } if ($XML_STORES_PARENT) { if ($this->bCatalog) { $result = $this->ImportStores($XML_STORES_PARENT); if ($result !== true) { return $result; } } } $this->next_step["section_sort"] = 100; $this->next_step["XML_SECTIONS_PARENT"] = $XML_SECTIONS_PARENT; return true; }
} //IBlock fields $iblock = new CIBlock(); $arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y')), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_NAME' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'SECTION_DESCRIPTION_TYPE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => 'text'), 'SECTION_DESCRIPTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'SECTION_XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y'))), "CODE" => "furniture_offers", "XML_ID" => $iblockCode); $iblock->Update($IBLOCK_OFFERS_ID, $arFields); $iblockCodeFur = "furniture_" . WIZARD_SITE_ID; $iblockTypeFur = "catalog"; $rsIBlockFur = CIBlock::GetList(array(), array("XML_ID" => $iblockCodeFur, "TYPE" => $iblockTypeFur)); if ($arIBlockFur = $rsIBlockFur->Fetch()) { $ID_SKU = CCatalog::LinkSKUIBlock($arIBlockFur["ID"], $IBLOCK_OFFERS_ID); } $arCatalog = CCatalog::GetByID($IBLOCK_OFFERS_ID); if ($arCatalog) { CCatalog::Update($IBLOCK_OFFERS_ID, array('PRODUCT_IBLOCK_ID' => $arIBlockFur["ID"], 'SKU_PROPERTY_ID' => $ID_SKU)); } else { CCatalog::Add(array('IBLOCK_ID' => $IBLOCK_OFFERS_ID, 'PRODUCT_IBLOCK_ID' => $arIBlockFur["ID"], 'SKU_PROPERTY_ID' => $ID_SKU)); } $dbOfferProps = CIblock::GetProperties($IBLOCK_OFFERS_ID, array(), array()); while ($arOfferProps = $dbOfferProps->Fetch()) { $arProps[$arOfferProps["XML_ID"]] = $arOfferProps["ID"]; } $property_enums = CIBlockPropertyEnum::GetList(array(), array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "CODE" => "WIDTH")); $arEnumIds = array(); while ($enum_fields = $property_enums->GetNext()) { $arEnumIds[] = $enum_fields["ID"]; } $dbElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlockFur["ID"], "XML_ID" => 56), false); $arElement = $dbElement->Fetch(); $arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_1"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[0], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_11")); $arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_1"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[1], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_12")); $dbElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlockFur["ID"], "XML_ID" => 55), false);
} else { $errMsg[] = Loc::getMessage('CRM_UPDATE_ERR_001'); return; } if (!empty($arCatalogId) && empty($errMsg)) { $CCatalog = new CCatalog(); if ($CCatalog) { foreach ($arCatalogId as $catalogId) { $arFields = array('IBLOCK_ID' => $catalogId, 'CATALOG' => 'Y'); if ($defCatVatId > 0) { $arFields['VAT_ID'] = $defCatVatId; } // add crm iblock to catalog $dbRes = $CCatalog->GetList(array(), array('ID' => $catalogId), false, false, array('ID')); if (!$dbRes->Fetch()) { if ($CCatalog->Add($arFields)) { COption::SetOptionString('catalog', 'save_product_without_price', 'Y'); COption::SetOptionString('catalog', 'default_can_buy_zero', 'Y'); } else { $errMsg[] = Loc::getMessage('CRM_UPDATE_ERR_002'); return; } } unset($dbRes); } // transfer crm products to catalog if ($basePriceId > 0) { if (COption::GetOptionString('crm', '~CRM_INVOICE_PRODUCTS_CONVERTED_12_5_7', 'N') !== 'Y') { if ($DB->TableExists('b_crm_product') && $DB->TableExists('b_catalog_product') && $DB->TableExists('b_catalog_price') && $DB->TableExists('b_catalog_group')) { // update iblock element xml_id $local_err = 0;
public function iShopImportMetaData($xml_root_id, $IBLOCK_TYPE, $IBLOCK_LID, $bUpdateIBlock = true) { global $APPLICATION; $rs = $this->_xml_file->GetList( array("ID" => "asc"), array("ID" => $xml_root_id), array("ID", "NAME", "ATTRIBUTES") ); $ar = $rs->Fetch(); if ($ar) { foreach(array(LANGUAGE_ID, "en", "ru") as $lang) { $mess = IncludeModuleLangFile(__FILE__, $lang, true); if($ar["NAME"] === $mess["IBLOCK_XML2_COMMERCE_INFO"]) { $this->mess = $mess; $this->next_step["lang"] = $lang; } } $xml_root_id = $ar["ID"]; } if($ar && (strlen($ar["ATTRIBUTES"]) > 0)) { $info = unserialize($ar["ATTRIBUTES"]); if(is_array($info) && array_key_exists($this->mess["IBLOCK_XML2_SUM_FORMAT"], $info)) { if(preg_match("#".$this->mess["IBLOCK_XML2_SUM_FORMAT_DELIM"]."=(.);{0,1}#", $info[$this->mess["IBLOCK_XML2_SUM_FORMAT"]], $match)) { $this->next_step["sdp"] = $match[1]; } } } $meta_data_xml_id = false; $XML_ELEMENTS_PARENT = false; $XML_SECTIONS_PARENT = false; $XML_PROPERTIES_PARENT = false; $XML_SECTIONS_PROPERTIES_PARENT = false; $XML_PRICES_PARENT = false; $XML_STORES_PARENT = false; $XML_BASE_UNITS_PARENT = false; $XML_SECTION_PROPERTIES = false; $arIBlock = array(); $this->next_step["bOffer"] = false; $rs = $this->_xml_file->GetList( array(), array("PARENT_ID" => $xml_root_id, "NAME" => $this->mess["IBLOCK_XML2_CATALOG"]), array("ID", "ATTRIBUTES") ); $ar = $rs->Fetch(); if(!$ar) { $rs = $this->_xml_file->GetList( array(), array("PARENT_ID" => $xml_root_id, "NAME" => $this->mess["IBLOCK_XML2_OFFER_LIST"]), array("ID", "ATTRIBUTES") ); $ar = $rs->Fetch(); $this->next_step["bOffer"] = true; } if(!$ar) { $rs = $this->_xml_file->GetList( array(), array("PARENT_ID" => $xml_root_id, "NAME" => $this->mess["IBLOCK_XML2_OFFERS_CHANGE"]), array("ID", "ATTRIBUTES") ); $ar = $rs->Fetch(); $this->next_step["bOffer"] = true; $this->next_step["bUpdateOnly"] = true; $bUpdateIBlock = false; } if ($this->next_step["bOffer"] && !$this->bCatalog) return GetMessage('IBLOCK_XML2_MODULE_CATALOG_IS_ABSENT'); if($ar) { if(strlen($ar["ATTRIBUTES"]) > 0) { $attrs = unserialize($ar["ATTRIBUTES"]); if(is_array($attrs)) { if(array_key_exists($this->mess["IBLOCK_XML2_UPDATE_ONLY"], $attrs)) $this->next_step["bUpdateOnly"] = ($attrs[$this->mess["IBLOCK_XML2_UPDATE_ONLY"]]=="true") || intval($attrs[$this->mess["IBLOCK_XML2_UPDATE_ONLY"]])? true: false; } } $rs = $this->_xml_file->GetList( array("ID" => "asc"), array("PARENT_ID" => $ar["ID"]) ); while($ar = $rs->Fetch()) { if(isset($ar["VALUE_CLOB"])) $ar["VALUE"] = $ar["VALUE_CLOB"]; if($ar["NAME"] == $this->mess["IBLOCK_XML2_ID"]) $arIBlock["XML_ID"] = ($this->use_iblock_type_id? $IBLOCK_TYPE."-": "").$ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_CATALOG_ID"]) $arIBlock["CATALOG_XML_ID"] = ($this->use_iblock_type_id? $IBLOCK_TYPE."-": "").$ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_NAME"]) $arIBlock["NAME"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_DESCRIPTION"]) { $arIBlock["DESCRIPTION"] = $ar["VALUE"]; $arIBlock["DESCRIPTION_TYPE"] = "html"; } elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_POSITIONS"] || $ar["NAME"] == $this->mess["IBLOCK_XML2_OFFERS"]) $XML_ELEMENTS_PARENT = $ar["ID"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_PRICE_TYPES"]) $XML_PRICES_PARENT = $ar["ID"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_STORES"]) $XML_STORES_PARENT = $ar["ID"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BASE_UNITS"]) $XML_BASE_UNITS_PARENT = $ar["ID"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_METADATA_ID"]) $meta_data_xml_id = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_UPDATE_ONLY"]) $this->next_step["bUpdateOnly"] = ($ar["VALUE"]=="true") || intval($ar["VALUE"])? true: false; // elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_CODE"]) // $arIBlock["CODE"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_SORT"]) $arIBlock["SORT"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_LIST_URL"]) $arIBlock["LIST_PAGE_URL"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_DETAIL_URL"]) $arIBlock["DETAIL_PAGE_URL"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_SECTION_URL"]) $arIBlock["SECTION_PAGE_URL"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_CANONICAL_URL"]) $arIBlock["CANONICAL_PAGE_URL"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_INDEX_ELEMENTS"]) $arIBlock["INDEX_ELEMENT"] = ($ar["VALUE"]=="true") || intval($ar["VALUE"])? "Y": "N"; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_INDEX_SECTIONS"]) $arIBlock["INDEX_SECTION"] = ($ar["VALUE"]=="true") || intval($ar["VALUE"])? "Y": "N"; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_SECTIONS_NAME"]) $arIBlock["SECTIONS_NAME"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_SECTION_NAME"]) $arIBlock["SECTION_NAME"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_ELEMENTS_NAME"]) $arIBlock["ELEMENTS_NAME"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_ELEMENT_NAME"]) $arIBlock["ELEMENT_NAME"] = $ar["VALUE"]; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_PICTURE"]) { if(strlen($ar["VALUE"]) > 0) $arIBlock["PICTURE"] = $this->MakeFileArray($ar["VALUE"]); else $arIBlock["PICTURE"] = $this->MakeFileArray($this->_xml_file->GetAllChildrenArray($ar["ID"])); } elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_BX_WORKFLOW"]) $arIBlock["WORKFLOW"] = ($ar["VALUE"]=="true") || intval($ar["VALUE"])? "Y": "N"; elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_INHERITED_TEMPLATES"]) { $arIBlock["IPROPERTY_TEMPLATES"] = array(); $arTemplates = $this->_xml_file->GetAllChildrenArray($ar["ID"]); foreach($arTemplates as $TEMPLATE) { $id = $TEMPLATE[$this->mess["IBLOCK_XML2_ID"]]; $template = $TEMPLATE[$this->mess["IBLOCK_XML2_VALUE"]]; if(strlen($id) > 0 && strlen($template) > 0) $arIBlock["IPROPERTY_TEMPLATES"][$id] = $template; } } elseif($ar["NAME"] == $this->mess["IBLOCK_XML2_LABELS"]) { $arLabels = $this->_xml_file->GetAllChildrenArray($ar["ID"]); foreach($arLabels as $arLabel) { $id = $arLabel[$this->mess["IBLOCK_XML2_ID"]]; $label = $arLabel[$this->mess["IBLOCK_XML2_VALUE"]]; if(strlen($id) > 0 && strlen($label) > 0) $arIBlock[$id] = $label; } } $arIBlock["CODE"] = DEFAULT_CATALOG_IBLOCK; } if($this->next_step["bOffer"] && !$this->use_offers) { if(strlen($arIBlock["CATALOG_XML_ID"]) > 0) { $arIBlock["XML_ID"] = $arIBlock["CATALOG_XML_ID"]; $this->next_step["bUpdateOnly"] = true; } } $obIBlock = new CIBlock; $rsIBlocks = $obIBlock->GetList(array(), array("CODE"=>DEFAULT_CATALOG_IBLOCK)); $ar = $rsIBlocks->Fetch(); //Also check for non bitrix xml file if(!$ar && !array_key_exists("CODE", $arIBlock)) { if($this->next_step["bOffer"] && $this->use_offers) $rsIBlocks = $obIBlock->GetList(array(), array("XML_ID"=>"FUTURE-1C-OFFERS")); else $rsIBlocks = $obIBlock->GetList(array(), array("XML_ID"=>"FUTURE-1C-CATALOG")); $ar = $rsIBlocks->Fetch(); } if($ar) { if($bUpdateIBlock && (!$this->next_step["bOffer"] || $this->use_offers)) { if($obIBlock->Update($ar["ID"], $arIBlock)) $arIBlock["ID"] = $ar["ID"]; else return $obIBlock->LAST_ERROR; } else { $arIBlock["ID"] = $ar["ID"]; } } else { $arIBlock["IBLOCK_TYPE_ID"] = $this->CheckIBlockType($IBLOCK_TYPE); if(!$arIBlock["IBLOCK_TYPE_ID"]) return GetMessage("IBLOCK_XML2_TYPE_ADD_ERROR"); $arIBlock["GROUP_ID"] = array(2=>"R"); $arIBlock["LID"] = $this->CheckSites($IBLOCK_LID); $arIBlock["ACTIVE"] = "Y"; $arIBlock["WORKFLOW"] = "N"; $arIBlock["CODE"] = DEFAULT_CATALOG_IBLOCK; if ( $this->translit_on_add && !array_key_exists("CODE", $arIBlock) ) { $arIBlock["FIELDS"] = array( "CODE" => array( "DEFAULT_VALUE" => array( "TRANSLITERATION" => "Y", "TRANS_LEN" => $this->translit_on_add["max_len"], "TRANS_CASE" => $this->translit_on_add["change_case"], "TRANS_SPACE" => $this->translit_on_add["replace_space"], "TRANS_OTHER" => $this->translit_on_add["replace_other"], "TRANS_EAT" => $this->translit_on_add["delete_repeat_replace"]? "Y": "N", )), "SECTION_CODE" => array( "DEFAULT_VALUE" => array( "TRANSLITERATION" => "Y", "TRANS_LEN" => $this->translit_on_add["max_len"], "TRANS_CASE" => $this->translit_on_add["change_case"], "TRANS_SPACE" => $this->translit_on_add["replace_space"], "TRANS_OTHER" => $this->translit_on_add["replace_other"], "TRANS_EAT" => $this->translit_on_add["delete_repeat_replace"]? "Y": "N", )), ); } $arIBlock["ID"] = $obIBlock->Add($arIBlock); if(!$arIBlock["ID"]) return $obIBlock->LAST_ERROR; } //Make this catalog if($this->bCatalog && $this->next_step["bOffer"]) { $obCatalog = new CCatalog(); $intParentID = $this->GetIBlockIdByCode(DEFAULT_CATALOG_IBLOCK); if (0 < intval($intParentID) && $this->use_offers) { $mxSKUProp = $obCatalog->LinkSKUIBlock($intParentID,$arIBlock["ID"]); if (!$mxSKUProp) { if ($ex = $APPLICATION->GetException()) { $result = $ex->GetString(); return $result; } } else { $rs = CCatalog::GetList(array(),array("IBLOCK_ID"=>$arIBlock["ID"])); if($arOffer = $rs->Fetch()) { $boolFlag = $obCatalog->Update($arIBlock["ID"],array('PRODUCT_IBLOCK_ID' => $intParentID,'SKU_PROPERTY_ID' => $mxSKUProp)); } else { $boolFlag = $obCatalog->Add(array("IBLOCK_ID"=>$arIBlock["ID"], "YANDEX_EXPORT"=>"N", "SUBSCRIPTION"=>"N",'PRODUCT_IBLOCK_ID' => $intParentID,'SKU_PROPERTY_ID' => $mxSKUProp)); } if (!$boolFlag) { if ($ex = $APPLICATION->GetException()) { $result = $ex->GetString(); return $result; } } } } else { $rs = CCatalog::GetList(array(),array("IBLOCK_ID"=>$arIBlock["ID"])); if(!($rs->Fetch())) { $boolFlag = $obCatalog->Add(array("IBLOCK_ID"=>$arIBlock["ID"], "YANDEX_EXPORT"=>"N", "SUBSCRIPTION"=>"N")); if (!$boolFlag) { if ($ex = $APPLICATION->GetException()) { $result = $ex->GetString(); return $result; } } } } } //For non bitrix xml file //Check for mandatory properties and add them as necessary if(!array_key_exists("CODE", $arIBlock)) { $arProperties = array( "CML2_BAR_CODE" => GetMessage("IBLOCK_XML2_BAR_CODE"), "CML2_ARTICLE" => GetMessage("IBLOCK_XML2_ARTICLE"), "CML2_ATTRIBUTES" => array( "NAME" => GetMessage("IBLOCK_XML2_ATTRIBUTES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, ), "CML2_TRAITS" => array( "NAME" => GetMessage("IBLOCK_XML2_TRAITS"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, ), "CML2_BASE_UNIT" => GetMessage("IBLOCK_XML2_BASE_UNIT_NAME"), "CML2_TAXES" => array( "NAME" => GetMessage("IBLOCK_XML2_TAXES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, ), "CML2_PICTURES" => array( "NAME" => GetMessage("IBLOCK_XML2_PICTURES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, "PROPERTY_TYPE" => "F", "CODE" => "MORE_PHOTO", ), "CML2_FILES" => array( "NAME" => GetMessage("IBLOCK_XML2_FILES"), "MULTIPLE" => "Y", "WITH_DESCRIPTION" => "Y", "MULTIPLE_CNT" => 1, "PROPERTY_TYPE" => "F", "CODE" => "FILES", ), "CML2_MANUFACTURER" => array( "NAME" => GetMessage("IBLOCK_XML2_PROP_MANUFACTURER"), "MULTIPLE" => "N", "WITH_DESCRIPTION" => "N", "MULTIPLE_CNT" => 1, "PROPERTY_TYPE" => "L", ), ); foreach($arProperties as $k=>$v) { $result = $this->CheckProperty($arIBlock["ID"], $k, $v); if($result!==true) return $result; } //For offers make special property: link to catalog if(isset($arIBlock["CODE"]) && $this->use_offers) $this->CheckProperty($arIBlock["ID"], "CML2_LINK", array( "NAME" => GetMessage("IBLOCK_XML2_CATALOG_ELEMENT"), "PROPERTY_TYPE" => "E", "USER_TYPE" => "SKU", "LINK_IBLOCK_ID" => $this->GetIBlockIdByCode(DEFAULT_CATALOG_IBLOCK), "FILTRABLE" => "Y", )); } $this->next_step["IBLOCK_ID"] = $arIBlock["ID"]; $this->next_step["XML_ELEMENTS_PARENT"] = $XML_ELEMENTS_PARENT; } if($meta_data_xml_id) { $rs = $this->_xml_file->GetList( array(), array("PARENT_ID" => $xml_root_id, "NAME" => $this->mess["IBLOCK_XML2_METADATA"]), array("ID") ); while($arMetadata = $rs->Fetch()) { //Find referenced metadata $bMetaFound = false; $meta_roots = array(); $rsMetaRoots = $this->_xml_file->GetList( array("ID" => "asc"), array("PARENT_ID" => $arMetadata["ID"]) ); while($arMeta = $rsMetaRoots->Fetch()) { if(isset($arMeta["VALUE_CLOB"])) $arMeta["VALUE"] = $arMeta["VALUE_CLOB"]; if($arMeta["NAME"] == $this->mess["IBLOCK_XML2_ID"] && $arMeta["VALUE"] == $meta_data_xml_id) $bMetaFound = true; $meta_roots[] = $arMeta; } //Get xml parents of the properties and sections if($bMetaFound) { foreach($meta_roots as $arMeta) { if($arMeta["NAME"] == $this->mess["IBLOCK_XML2_GROUPS"]) $XML_SECTIONS_PARENT = $arMeta["ID"]; elseif($arMeta["NAME"] == $this->mess["IBLOCK_XML2_PROPERTIES"]) $XML_PROPERTIES_PARENT = $arMeta["ID"]; elseif($arMeta["NAME"] == $this->mess["IBLOCK_XML2_GROUPS_PROPERTIES"]) $XML_SECTIONS_PROPERTIES_PARENT = $arMeta["ID"]; elseif($arMeta["NAME"] == $this->mess["IBLOCK_XML2_SECTION_PROPERTIES"]) $XML_SECTION_PROPERTIES = $arMeta["ID"]; elseif($arMeta["NAME"] == $this->mess["IBLOCK_XML2_PRICE_TYPES"]) $XML_PRICES_PARENT = $arMeta["ID"]; elseif($arMeta["NAME"] == $this->mess["IBLOCK_XML2_STORES"]) $XML_STORES_PARENT = $arMeta["ID"]; elseif($arMeta["NAME"] == $this->mess["IBLOCK_XML2_BASE_UNITS"]) $XML_BASE_UNITS_PARENT = $arMeta["ID"]; } break; } } } $iblockFields = CIBlock::GetFields($arIBlock["ID"]); $iblockFields["XML_IMPORT_START_TIME"] = array( "NAME" => "XML_IMPORT_START_TIME", "IS_REQUIRED" => "N", "DEFAULT_VALUE" => date("Y-m-d H:i:s"), ); CIBlock::SetFields($arIBlock["ID"], $iblockFields); if($XML_PROPERTIES_PARENT) { $result = $this->ImportProperties($XML_PROPERTIES_PARENT, $arIBlock["ID"]); if($result!==true) return $result; } if($XML_SECTION_PROPERTIES) { $result = $this->ImportSectionProperties($XML_SECTION_PROPERTIES, $arIBlock["ID"]); if($result!==true) return $result; } if($XML_SECTIONS_PROPERTIES_PARENT) { $result = $this->ImportSectionsProperties($XML_SECTIONS_PROPERTIES_PARENT, $arIBlock["ID"]); if($result!==true) return $result; } if($XML_PRICES_PARENT) { if($this->bCatalog) { $result = $this->ImportPrices($XML_PRICES_PARENT, $arIBlock["ID"], $IBLOCK_LID); if($result!==true) return $result; } } if($XML_STORES_PARENT) { if($this->bCatalog && CBXFeatures::IsFeatureEnabled('CatMultiStore')) { $result = $this->ImportStores($XML_STORES_PARENT); if($result!==true) return $result; } } if($XML_BASE_UNITS_PARENT) { if($this->bCatalog) { $result = $this->ImportBaseUnits($XML_BASE_UNITS_PARENT); if($result!==true) return $result; } } $this->next_step["section_sort"] = 100; $this->next_step["XML_SECTIONS_PARENT"] = $XML_SECTIONS_PARENT; $rs = $this->_xml_file->GetList( array(), array("PARENT_ID" => $xml_root_id, "NAME" => $this->mess["IBLOCK_XML2_PRODUCTS_SETS"]), array("ID", "ATTRIBUTES") ); $ar = $rs->Fetch(); if ($ar) { $this->next_step["SETS"] = $ar["ID"]; } return true; }