R
R
ragnar_ok2019-10-22 18:09:32
1C-Bitrix
ragnar_ok, 2019-10-22 18:09:32

How to filter using CIBlockElement::SubQuery()?

CIBlockElement::SubQuery();does not filter by ACTIVE(or any other field/property). The filter is not applied. Outputs all elements.

$elementObj = CIBlockElement::GetList(
    [], 
    [
        'IBLOCK_ID' => 4,
        //'PROPERTY_REL_ID.ACTIVE' => 'N', // Это работает!
        'ID' => CIBlockElement::SubQuery('PROPERTY_REL_ID', [
            'IBLOCK_ID' => 1,
            'ACTIVE' => 'N'
        ]),
    ],
    false,
    false,
    ['ID', 'IBLOCK_ID', 'NAME']
);
    
while ($elementArray = $elementObj->Fetch()) {
    $resultArray[] = $elementArray;
}

Thus if to use $arFilter = ['PROPERTY_REL_ID.ACTIVE' => 'N'], then filters. But I need a filter by property.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Georgy Baruchyan, 2019-10-22
@Snatch87

Try like this:

[
        'IBLOCK_ID' => 4,

        'PROPERTY_REL_ID' => CIBlockElement::SubQuery('ID', [
            'IBLOCK_ID' => 1,
            'ACTIVE' => 'N'
        ]),
    ],
    false,
    false,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question