- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
- Класс: CIBlockCMLImport
- Вызов: CIBlockCMLImport::ReadCatalogData
function ReadCatalogData(&$SECTION_MAP, &$PRICES_MAP)
{
if(!is_array($SECTION_MAP))
{
$SECTION_MAP = array();
$rsSections = CIBlockSection::GetList(array(), array("IBLOCK_ID"=>$this->next_step["IBLOCK_ID"]), false);
while($ar = $rsSections->Fetch())
$SECTION_MAP[$ar["XML_ID"]] = $ar["ID"];
unset($rsSections);
}
$this->SECTION_MAP = $SECTION_MAP;
if(!is_array($PRICES_MAP))
{
$arPrices = array();
if($this->bCatalog)
{
$arPrices = CCatalogGroup::GetListArray();
}
$PRICES_MAP = array();
if(isset($this->next_step["XML_PRICES_PARENT"]))
{
$rs = $this->_xml_file->GetList(
array("ID" => "asc"),
array("PARENT_ID" => $this->next_step["XML_PRICES_PARENT"])
);
while($arParent = $rs->Fetch())
{
if(isset($arParent["VALUE_CLOB"]))
$arParent["VALUE"] = $arParent["VALUE_CLOB"];
$arXMLPrice = $this->_xml_file->GetAllChildrenArray($arParent);
$PRICE_ID = $arXMLPrice[$this->mess["IBLOCK_XML2_ID"]];
$PRICE_NAME = $arXMLPrice[$this->mess["IBLOCK_XML2_NAME"]];
$arPrice = array(
"NAME" => $PRICE_NAME,
"XML_ID" => $PRICE_ID,
"CURRENCY" => $arXMLPrice[$this->mess["IBLOCK_XML2_CURRENCY"]] ?? '',
"TAX_NAME" => $arXMLPrice[$this->mess["IBLOCK_XML2_TAX"]][$this->mess["IBLOCK_XML2_NAME"]] ?? '',
"TAX_IN_SUM" => $arXMLPrice[$this->mess["IBLOCK_XML2_TAX"]][$this->mess["IBLOCK_XML2_IN_SUM"]] ?? '',
);
if($this->bCatalog)
{
$found_id = 0;
//Check for price by XML_ID
if (isset($PRICE_ID) && $PRICE_ID != "")
{
foreach($arPrices as $price)
{
if ($PRICE_ID === $price["XML_ID"])
{
$found_id = $price["ID"];
break;
}
}
}
//When lookup by it's name
if (!$found_id)
{
foreach($arPrices as $price)
{
if ($PRICE_NAME === $price["NAME"])
{
$found_id = $price["ID"];
break;
}
}
}
if($found_id)
$arPrice["ID"] = $found_id;
else
$arPrice["ID"] = 0;
}
else
{
$obProperty = new CIBlockProperty;
$rsProperty = $obProperty->GetList(array(), array("IBLOCK_ID"=>$this->next_step["IBLOCK_ID"], "XML_ID"=>$arPrice["XML_ID"]));
if($ar = $rsProperty->Fetch())
$arPrice["ID"] = $ar["ID"];
else
$arPrice["ID"] = 0;
}
$PRICES_MAP[$PRICE_ID] = $arPrice;
}
}
else
{
foreach($arPrices as $arPrice)
{
$arPrice['TAX_NAME'] = '';
$arPrice['TAX_IN_SUM'] = '';
$PRICES_MAP[$arPrice["XML_ID"]] = $arPrice;
}
}
}
$this->PRICES_MAP = $PRICES_MAP;
}