Answer the question
In order to leave comments, you need to log in
How to reduce the number of requests to get the "Directory" property?
I get the "Directory" property. The number of requests is equal to the number of loop iterations:
foreach ($arResult['ITEMS'] as $index => $arItem) {
$resultArray = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity('Entity')->getDataClass()::getList([
'select' => ['UF_NAME'],
'filter' => ['UF_XML_ID' => $arItem['PROPERTIES']['PROP']['VALUE']],
]);
while ($rowArray = $resultObj->fetch()) {
$arResult['ITEMS'][$index]['PROPERTIES']['PROP']['UF_NAME'] = $resultArray['UF_NAME'];
}
}
$arResult['ITEMS'][$index]['PROPERTIES']['PROP']['UF_NAME']
Answer the question
In order to leave comments, you need to log in
First you need to collect an array of all xml_id for which you will search
$xmlIds = [];
foreach ($arResult['ITEMS'] as $index => $arItem) {
$xmlIds[] = $arItem['PROPERTIES']['PROP']['VALUE']];
}
if(!empty($xmlIds)){
$resultArray = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity('Entity')->getDataClass()::getList([
'select' => ['UF_NAME'],
'filter' => ['@UF_XML_ID' => $xmlIds],
]);
while ($rowArray = $resultObj->fetch()) {
$arRef[$resultArray['UF_XML_ID']] = $resultArray['UF_NAME'];
}
}
If straight stupidly in the forehead:
$arRef = [];
$resultArray = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity('Entity')->getDataClass()::getList([
'select' => ['UF_NAME'],
'filter' => [],
]);
while ($rowArray = $resultObj->fetch()) {
$arRef[$resultArray['UF_XML_ID']] = $resultArray['UF_NAME'];
}
foreach ($arResult['ITEMS'] as $index => $arItem) {
$arResult['ITEMS'][$index]['PROPERTIES']['PROP']['UF_NAME'] = $arRef[$arItem['PROPERTIES']['PROP']['VALUE']];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question