I
I
I'm Yoda2018-04-12 09:51:10
1C-Bitrix
I'm Yoda, 2018-04-12 09:51:10

How to make a filter with complex logic?

Hi all!
I'm trying to display the minimum value of the property "PROPERTY_SIZE" (number) of all elements in a section. I actually get the value, but the logic doesn't work that way. I make a selection:

$arOrder = array("sort" => "asc");
    $arFilter = array("IBLOCK_ID" => $arSection["IBLOCK_ID"], "SECTION_ID" => $arSection["ID"], "GLOBAL_ACTIVE" => "Y", "ACTIVE" => "Y", "INCLUDE_SUBSECTIONS" => "Y", array(
            "LOGIC" => "OR",
            array("PROPERTY_DESTINATION_VALUE" => "TOP", "PROPERTY_DESTINATION_VALUE" => "MIDDLE", "PROPERTY_DESTINATION_VALUE" => "BOTTOM"),
        ),
        "!PROPERTY_SIZE" => false
    );
    $arSelect = array("IBLOCK_ID", "ID", "NAME", "PROPERTY_SIZE");

    $res = CIBlockElement::GetList($arOrder, $arFilter, false, array("nTopCount" => 1), $arSelect);
    if ($ob = $res->Fetch())
        $arSection["MIN_SIZE"] = $ob["PROPERTY_SIZE_VALUE"];

In the section, elements can have one value "TOP, MIDDLE, BOTTOM" of the property "PROPERTY_DESTINATION_VALUE"
In the first section, 10 elements with a property value (5 - TOP, 3 -MIDDLE, 2 - BOTTOM);
In the second section there are 10 elements with a property value (8 - MIDDLE, 2 - BOTTOM): In
the third section there are 5 elements with a property value (5 - BOTTOM):
by value MIDDLE and for the third by value BOTTOM, i.e. so that the sampling priority is 1 - TOP, 2 - MIDDLE, 3 - BOTTOM

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2018-04-12
@gromdron

Most likely, Bitrix will no longer be able to handle such logic and you need to access SQL and form a direct query in the database. Or, you can make an intermediate table / infoblock / highloadblock and already search there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question