C
C
Cyril2016-06-30 01:24:36
1C-Bitrix
Cyril, 2016-06-30 01:24:36

How to filter by the value of the infoblock property in Bitrix D7?

Hello! I decided to transfer to a new core, but everywhere I plugged it. The next question is how to filter elements by property?
As it was before:
$arFilter = array('PROPERTY_XXX'=>'YYY');
Well, then we pass it to CIBlock::GetList.
Now I try like this:

\Bitrix\Main\Loader::includeModule('iblock');

$queryPost = new \Bitrix\Main\Entity\Query(\Bitrix\Iblock\ElementTable::getEntity());

$queryPost
    ->setSelect(array(
        'ID','IBLOCK_ID'
    ))
    ->setFilter(array(
        'IBLOCK_ID' => 4,
        'PROPERTY_SHOW_ON_MAIN' => 'Y'
    ))
    ->setLimit(1);

$arRes = $queryPost->exec()->fetchAll();

I get an error
Unknown field definition `UF_SHOW_ON_MAIN` (UF_SHOW_ON_MAIN) for Element Entity. (100)

In general, it is clear why - the table really does not have such fields .. But then how to filter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
msk-develop, 2016-07-01
@ldeimosl

If you have infoblock 2.0, then there is info here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question