Answer the question
In order to leave comments, you need to log in
How to filter custom properties in bitrix ORM?
I am trying to execute the following query
$res = Bitrix\Iblock\ElementTable::getList(array(
'select' => array('ID', 'CODE'),
'filter' => array(
'=IBLOCK_ID' => 9,
'=ACTIVE'=>'Y',
'!PROPERTY_OWN' => false
)
)
);
Unknown field definition `PROPERTY_OWN` (PROPERTY_OWN) for Element Entity. (100)
Answer the question
In order to leave comments, you need to log in
Not out of the box yet. You can compile an entity with properties on the fly and add it to the selection through the runtime section in the getlist.
Example (for properties in a separate table):
//<?php
\Bitrix\Main\Loader::includeModule('iblock');
$iblockId = 155;
$entityPropsSingle = Bitrix\Main\Entity\Base::compileEntity(
sprintf('PROPS_SINGLE_%s', $iblockId),
[
'IBLOCK_ELEMENT_ID' => ['data_type' => 'integer'],
'PROPERTY_1020' => ['data_type' => 'integer'],
],
[
'table_name' => sprintf('b_iblock_element_prop_s%s', $iblockId),
]
);
\Bitrix\Main\Application::getConnection()->startTracker();
$result = \Bitrix\Iblock\ElementTable::getList([
'select' => [
'ID',
'NAME',
'PROPS_SINGLE.*',
],
'filter' => [
'>PROPS_SINGLE.PROPERTY_1020' => 0,
],
'order' => [
'PROPS_SINGLE.PROPERTY_1020' => 'ASC',
],
'runtime' => [
'PROPS_SINGLE' => [
'data_type' => $entityPropsSingle->getDataClass(),
'reference' => [
'=this.ID' => 'ref.IBLOCK_ELEMENT_ID'
],
'join_type' => 'inner'
],
],
]);
// Можно смотреть сформированный запрос
echo '<pre>', $result->getTrackerQuery()->getSql(), '</pre>';
echo '<pre>';print_r($result->fetchAll());echo '</pre>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question