function exportElement($arElement, $SECTION_MAP, $PROPERTY_MAP)
{
if($arElement["XML_ID"] <> '')
$xml_id = $arElement["XML_ID"];
else
$xml_id = $arElement["ID"];
if($this->PRODUCT_IBLOCK_ID > 0)
{
$arPropOrder = array(
"sort" => "asc",
"id" => "asc",
"enum_sort" => "asc",
"value_id" => "asc",
);
$rsLink = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE"=>"Y", "CODE" => "CML2_LINK"));
$arLink = $rsLink->Fetch();
if(is_array($arLink) && !is_array($arLink["VALUE"]) && $arLink["VALUE"] > 0)
{
$parent_xml_id = $this->GetElementXML_ID($this->PRODUCT_IBLOCK_ID, $arLink["VALUE"]);
if ($parent_xml_id === $xml_id)
$xml_id = $parent_xml_id;
else
{
[$productXmlId, $offerXmlId] = explode("#", $xml_id, 2);
if ($productXmlId !== $parent_xml_id)
$xml_id = $parent_xml_id."#".$xml_id;
}
}
}
fwrite($this->fp, "tttt<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($xml_id)."".GetMessage("IBLOCK_XML2_ID").">n");
if(($aliasXmlId = $this->aliasXmlId($xml_id))>0)
fwrite($this->fp, $aliasXmlId);
if(!$this->only_price)
{
$this->exportElementFields($arElement, $SECTION_MAP);
if($this->next_step["catalog"] && !$this->bExtended)
fwrite($this->fp, "tttt<".GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTES").">n");
else
fwrite($this->fp, "tttt<".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">n");
$this->exportElementProperties($arElement, $PROPERTY_MAP);
if($this->next_step["catalog"] && !$this->bExtended)
fwrite($this->fp, "tttt".GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTES").">n");
else
fwrite($this->fp, "tttt".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">n");
if($this->bExtended)
{
$elementTemplates = new BitrixIblockInheritedPropertyElementTemplates($this->arIBlock["ID"], $arElement["ID"]);
$this->exportInheritedTemplates(4, $elementTemplates);
}
}
if($this->next_step["catalog"])
{
static $measure = null;
if (!isset($measure))
{
$measure = array();
$rsBaseUnit = CCatalogMeasure::GetList(array(), array());
while($arIDUnit = $rsBaseUnit->Fetch())
$measure[$arIDUnit["ID"]] = $arIDUnit["CODE"];
}
static $systemFieldTypes = null;
if (!isset($systemFieldTypes))
{
$systemFieldTypes = [];
if (ProductSystemFieldMarkingCodeGroup::isAllowed())
{
$systemFieldTypes[ProductSystemFieldMarkingCodeGroup::FIELD_ID] = array_fill_keys(
ProductSystemFieldMarkingCodeGroup::getAllowedProductTypeList(),
true
);
}
if (ProductSystemFieldProductMapping::isAllowed())
{
$systemFieldTypes[ProductSystemFieldProductMapping::FIELD_ID] = array_fill_keys(
ProductSystemFieldProductMapping::getAllowedProductTypeList(),
true
);
}
}
//TODO: change this code after refactoring product system fields
$selectFields = ['ID', 'MEASURE', 'QUANTITY', 'TYPE', 'WIDTH', 'LENGTH', 'HEIGHT'];
$productSystemFields = CatalogProductSystemField::getExportSelectFields();
$selectFields = array_merge($selectFields, $productSystemFields);
$iterator = CatalogProductTable::getList([
'select' => $selectFields,
'filter' => ['=ID' => $arElement['ID']]
]);
$row = $iterator->fetch();
unset($iterator);
if (!empty($row) && is_array($row))
{
ProductSystemField::prepareRow($row, ProductSystemField::OPERATION_EXPORT);
$row['TYPE'] = (int)$row['TYPE'];
if (
isset($systemFieldTypes[ProductSystemFieldMarkingCodeGroup::FIELD_ID])
&& isset($systemFieldTypes[ProductSystemFieldMarkingCodeGroup::FIELD_ID][$row['TYPE']])
)
{
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_MARKING_CODE_GROUP").">"
.htmlspecialcharsbx((string)$row[ProductSystemFieldMarkingCodeGroup::FIELD_ID])
."".GetMessage("IBLOCK_XML2_MARKING_CODE_GROUP").">n"
);
}
if (
isset($systemFieldTypes[ProductSystemFieldProductMapping::FIELD_ID])
&& isset($systemFieldTypes[ProductSystemFieldProductMapping::FIELD_ID][$row['TYPE']])
)
{
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_PRODUCT_MAPPING").">n"
);
if (
!empty($row[ProductSystemFieldProductMapping::FIELD_ID])
&& is_array($row[ProductSystemFieldProductMapping::FIELD_ID])
)
{
foreach ($row[ProductSystemFieldProductMapping::FIELD_ID] as $value)
{
fwrite(
$this->fp,
"ttttt<".GetMessage('IBLOCK_XML2_ID').">"
.htmlspecialcharsbx($value)
."".GetMessage('IBLOCK_XML2_ID').">n"
);
}
}
fwrite(
$this->fp,
"tttt".GetMessage("IBLOCK_XML2_PRODUCT_MAPPING").">n"
);
}
if (
$row['TYPE'] == CatalogProductTable::TYPE_PRODUCT
|| $row['TYPE'] == CatalogProductTable::TYPE_SET
|| $row['TYPE'] == CatalogProductTable::TYPE_OFFER
|| (
$row['TYPE'] == CatalogProductTable::TYPE_SKU
&& MainConfigOption::get('catalog', 'show_catalog_tab_with_offers') === 'Y'
)
)
{
$row['MEASURE'] = (int)$row['MEASURE'];
$xmlMeasure = GetMessage("IBLOCK_XML2_PCS");
if ($row["MEASURE"] > 0 && isset($measure[$row["MEASURE"]]))
$xmlMeasure = $measure[$row["MEASURE"]];
$arPrices = [];
$rsPrices = CatalogPriceTable::getList([
'select' => ['ID', 'CATALOG_GROUP_ID', 'PRICE', 'CURRENCY', 'QUANTITY_FROM', 'QUANTITY_TO'],
'filter' => ['=PRODUCT_ID' => $arElement['ID']]
]);
while($arPrice = $rsPrices->fetch())
{
$arPrices[] = [
GetMessage("IBLOCK_XML2_PRICE_TYPE_ID") => $this->prices[$arPrice["CATALOG_GROUP_ID"]],
GetMessage("IBLOCK_XML2_PRICE_FOR_ONE") => $arPrice["PRICE"],
GetMessage("IBLOCK_XML2_CURRENCY") => $arPrice["CURRENCY"],
GetMessage("IBLOCK_XML2_MEASURE") => $xmlMeasure,
GetMessage("IBLOCK_XML2_QUANTITY_FROM") => $arPrice["QUANTITY_FROM"],
GetMessage("IBLOCK_XML2_QUANTITY_TO") => $arPrice["QUANTITY_TO"],
];
}
unset($arPrice);
unset($rsPrices);
if (!empty($arPrices))
{
fwrite($this->fp, "tttt<".GetMessage("IBLOCK_XML2_PRICES").">n");
foreach($arPrices as $arPrice)
{
fwrite($this->fp, "ttttt<".GetMessage("IBLOCK_XML2_PRICE").">n");
foreach($arPrice as $key=>$value)
{
fwrite($this->fp, "tttttt<".$key.">".htmlspecialcharsbx($value)."".$key.">n");
}
fwrite($this->fp, "ttttt".GetMessage("IBLOCK_XML2_PRICE").">n");
}
fwrite($this->fp, "tttt".GetMessage("IBLOCK_XML2_PRICES").">n");
}
unset($arPrices);
if ($row['TYPE'] != CatalogProductTable::TYPE_SET)
{
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_AMOUNT").">"
.htmlspecialcharsbx($row["QUANTITY"])
."".GetMessage("IBLOCK_XML2_AMOUNT").">n"
);
}
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_BASE_UNIT").">"
.htmlspecialcharsbx($xmlMeasure)
."".GetMessage("IBLOCK_XML2_BASE_UNIT").">n"
);
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_WIDTH").">"
.htmlspecialcharsbx($row["WIDTH"])
."".GetMessage("IBLOCK_XML2_WIDTH").">n"
);
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_LENGTH").">"
.htmlspecialcharsbx($row["LENGTH"])
."".GetMessage("IBLOCK_XML2_LENGTH").">n"
);
fwrite(
$this->fp,
"tttt<".GetMessage("IBLOCK_XML2_HEIGHT").">"
.htmlspecialcharsbx($row["HEIGHT"])
."".GetMessage("IBLOCK_XML2_HEIGHT").">n"
);
}
}
unset($row);
}
}