Answer the question
In order to leave comments, you need to log in
How to filter in Bitrix ORM by property if the selection consists of 2 infoblocks?
I'm trying to get elements from two infoblocks sorted by creation date.
Properties are stored in a separate table
here How to filter custom properties in bitrix ORM? found an approximate solution, it works if you make a selection of one IS, if you do it from 2, then it does not work
$iblockId = 32;
$entityPropsSingle = \Bitrix\Main\Entity\Base::compileEntity(
sprintf('PROPS_SINGLE_%s', $iblockId),
[
'IBLOCK_ELEMENT_ID' => ['data_type' => 'integer'],
'PROPERTY_1087' => ['data_type' => 'integer'],
],
[
'table_name' => sprintf('b_iblock_element_prop_s%s', $iblockId),
]
);
$iblockId = 33;
$entityPropsSingle1 = \Bitrix\Main\Entity\Base::compileEntity(
sprintf('PROPS_SINGLE_%s', $iblockId),
[
'IBLOCK_ELEMENT_ID' => ['data_type' => 'integer'],
'PROPERTY_1096' => ['data_type' => 'integer'],
],
[
'table_name' => sprintf('b_iblock_element_prop_s%s', $iblockId),
]
);
$params = [
'order' => array('DATE_CREATE' => 'DESC'),
'select' => array('ID', 'NAME', 'IBLOCK_ID', 'DATE_CREATE'),
'filter' => array('IBLOCK_ID' => $this->arParams['IBLOCK_IDS'],
[
'LOGIC' => 'OR',
['PROPS_SINGLE_32.PROPERTY_1087' => 1011,
'PROPS_SINGLE_33.PROPERTY_1096' => 1015],
]),
'runtime' => array(
'PROPS_SINGLE_32' => [
'data_type' => $entityPropsSingle->getDataClass(),
'reference' => [
'=this.ID' => 'ref.IBLOCK_ELEMENT_ID'
],
'join_type' => 'inner'
],
'PROPS_SINGLE_33' => [
'data_type' => $entityPropsSingle1->getDataClass(),
'reference' => [
'=this.ID' => 'ref.IBLOCK_ELEMENT_ID'
],
'join_type' => 'inner'
],
),
'cache' => array(
'ttl' => 3600,
'cache_joins' => true
),
];
$params['limit'] = $limit;
$params['offset'] = $offset;
$itemsRequest = \Bitrix\Iblock\ElementTable::getList($params);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question