- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
- Класс: CIBlockCMLImport
- Вызов: CIBlockCMLImport::ImportProductSets
function ImportProductSets()
{
if ($this->bCatalog && isset($this->next_step["SETS"]) && $this->next_step["SETS"] > 0)
{
$rsParents = $this->_xml_file->GetList(
array("ID" => "asc"),
array("PARENT_ID" => $this->next_step["SETS"]),
array("ID", "LEFT_MARGIN", "RIGHT_MARGIN")
);
while($arParent = $rsParents->Fetch())
{
$arXMLElement = $this->_xml_file->GetAllChildrenArray($arParent);
if(isset($arXMLElement[$this->mess["IBLOCK_XML2_ID"]]))
{
$rsElement = CIBlockElement::GetList(
array(),
array("=XML_ID" => $arXMLElement[$this->mess["IBLOCK_XML2_ID"]], "IBLOCK_ID" => $this->next_step["IBLOCK_ID"]),
false, false,
array("ID", "IBLOCK_ID")
);
if ($arDBElement = $rsElement->Fetch())
{
CCatalogProductSet::deleteAllSetsByProduct($arDBElement["ID"], CCatalogProductSet::TYPE_GROUP);
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_PRODUCT_SET"]]))
{
$arFields = array(
"ITEM_ID" => $arDBElement["ID"],
"TYPE" => CCatalogProductSet::TYPE_GROUP,
"ITEMS" => array(),
);
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_PRODUCT_SET"]] as $xmlSet)
{
$arFields["ITEMS"][] = array(
"ITEM_ID" => $this->GetElementByXML_ID($arDBElement["IBLOCK_ID"], $xmlSet[$this->mess["IBLOCK_XML2_VALUE"]]),
"SORT" => intval($xmlSet[$this->mess["IBLOCK_XML2_SORT"]]),
"QUANTITY" => intval($xmlSet[$this->mess["IBLOCK_XML2_AMOUNT"]]),
);
}
$ps = new CCatalogProductSet;
$ps->add($arFields);
}
}
}
}
}
}