- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
- Класс: CIBlockCMLImport
- Вызов: CIBlockCMLImport::ImportStores
function ImportStores($XML_STORES_PARENT)
{
$error = '';
$ID = 0;
$arDBStores = $this->getStoreList();
$arXMLStores = $this->_xml_file->GetAllChildrenArray($XML_STORES_PARENT);
foreach($arXMLStores as $arXMLStore)
{
$arStore = array(
"TITLE" => $arXMLStore[$this->mess["IBLOCK_XML2_NAME"]],
"XML_ID" => $arXMLStore[$this->mess["IBLOCK_XML2_ID"]],
);
if(isset($arXMLStore[$this->mess["IBLOCK_XML2_STORE_ADDRESS"]]))
$arStore["ADDRESS"] = $arXMLStore[$this->mess["IBLOCK_XML2_STORE_ADDRESS"]][$this->mess["IBLOCK_XML2_VIEW"]];
if(isset($arXMLStore[$this->mess["IBLOCK_XML2_STORE_DESCRIPTION"]]))
$arStore["DESCRIPTION"] = $arXMLStore[$this->mess["IBLOCK_XML2_STORE_DESCRIPTION"]];
if(
isset($arXMLStore[$this->mess["IBLOCK_XML2_STORE_CONTACTS"]])
&& is_array($arXMLStore[$this->mess["IBLOCK_XML2_STORE_CONTACTS"]])
)
{
$storeContact = array();
foreach($arXMLStore[$this->mess["IBLOCK_XML2_STORE_CONTACTS"]] as $arContact)
{
if (
is_array($arContact)
&& (
!isset($arContact[$this->mess["IBLOCK_XML2_TYPE"]])
|| mb_substr($arContact[$this->mess["IBLOCK_XML2_TYPE"]], 0, mb_strlen($this->mess["IBLOCK_XML2_STORE_PHONE"])) === $this->mess["IBLOCK_XML2_STORE_PHONE"]
)
)
{
$storeContact[] = $arContact[$this->mess["IBLOCK_XML2_VALUE"]];
}
}
if($storeContact)
$arStore["PHONE"] = implode(", ", $storeContact);
}
if (!isset($arDBStores[$arStore["XML_ID"]]))
{
if ((count($arDBStores) < 1) || CatalogConfigFeature::isMultiStoresEnabled())
$arDBStores[$arStore["XML_ID"]] = $ID = CCatalogStore::Add($arStore);
else
$error = GetMessage("IBLOCK_XML2_MULTI_STORE_IMPORT_ERROR");
}
else
{
if ((count($arDBStores) <= 1) || CatalogConfigFeature::isMultiStoresEnabled())
$ID = CCatalogStore::Update($arDBStores[$arStore["XML_ID"]], $arStore);
else
$error = GetMessage("IBLOCK_XML2_MULTI_STORE_IMPORT_ERROR");
}
}
if($error)
return $error;
if(!$ID)
return false;
return true;
}