$elements = [];
$listElements = ElementTable::getList([
'select' => selectElements(),
'runtime' => runtimeElements(),
'filter' => filterElements(),
'order' => orderElements(),
'group' => groupElements(),
]);
while ($tmpElement = $listElements->fetch()){
$elements[] = $tmpElement;
}
function selectElements(): array
{
return [
'DARK_PHOTO_VALUE' => 'DARK_PHOTO',
'LIGHT_PHOTO_VALUE' => 'LIGHT_PHOTO',
];
}
function filterElements(): array {
return [
'IBLOCK_ID' => $iblockId,
'ACTIVE' => 'Y',
];
}
protected function runtimeElements() : array{
return [
new Entity\ReferenceField(
'DARK_PHOTO',
\Bitrix\Iblock\ElementPropertyTable::class,
Query\Join::on('this.ID', 'ref.IBLOCK_ELEMENT_ID')
->where("ref.IBLOCK_PROPERTY_ID", '=', $this->getPropertyDarkPhotoId())
),
new Entity\ReferenceField(
'LIGHT_PHOTO',
\Bitrix\Iblock\ElementPropertyTable::class,
Query\Join::on('this.ID', 'ref.IBLOCK_ELEMENT_ID')
->where("ref.IBLOCK_PROPERTY_ID", '=', $this->getPropertyLightPhotoId())
),
];
}
function getPropertyDarkPhotoId()
{
if($id = $this->getPropertyInfo('DARK_PHOTO')['ID'])
return $id;
return 0;
}
function getPropertyLightPhotoId()
{
if($id = $this->getPropertyInfo('LIGHT_PHOTO')['ID'])
return $id;
return 0;
}
//Файл contactspropertytable.php
//Обязательно наследует DataManager
class ContactsPropertyTable extends DataManager
{
// Не обязательно
private static int $tableID, $propertyID;
// Не обязательно
public function __construct($tableID, $propertyID)
{
self::$propertyID = $propertyID;
self::$tableID = $tableID;
}
public static function getTableName()
{
return 'b_iblock_element_prop_s'.self::$tableID;
}
public static function getMap()
{
return [
(new IntegerField('IBLOCK_ELEMENT_ID'))
->configurePrimary(true),
new StringField('PROPERTY_'.self::$propertyID),
];
}
}
//Файл contacts.php своего модуля
protected function runtimeElements(): array
{
new ContactsPropertyTable($this->iblockId, $this->getPropertyLinkId());
return [
new Entity\ReferenceField(
"LINK",
ContactsPropertyTable::class,
Query\Join::on('this.ID', 'ref.IBLOCK_ELEMENT_ID')
),
];
}