S
S
sagaton2022-03-24 17:41:36
1C-Bitrix
sagaton, 2022-03-24 17:41:36

How to condition an array?

There is a get request

global $arrFilter;

    if($_GET['filter_hit'] == 'Y')
        $arrFilter[] = array("PROPERTY_YAVLYAETSI_VALUE"=>"популярным");

        if($_GET['filter_new'] == 'Y')
            $arrFilter[] = array("PROPERTY_YAVLYAETSI_VALUE"=>"новинкой");

        if($_GET['filter_sale'] == 'Y')
            $arrFilter[] = array("PROPERTY_YAVLYAETSI_VALUE"=>"акцией");

They work correctly.
When I try to redo it so that there are several requests, then there is already a problem
global $arrFilter;
   
        $arrFilter=array(
            "IBLOCK_ID" => "7",array( "LOGIC" => "OR",array("PROPERTY_YAVLYAETSI_VALUE"=="популярным"),array("PROPERTY_YAVLYAETSI_VALUE"=="новинкой"),array("PROPERTY_YAVLYAETSI_VALUE"=>"акцией")),);

prints all elements that have one of the 3 properties active.
How to make it so that the condition is supposedly clicked New items are displayed.
If you clicked on promotions, then more promotions were added to the list of new products, and if there is a third one, then all 3?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
no_one_safe, 2022-03-24
@sagaton

global $arrFilter;
        $arrFilter = array(
            "IBLOCK_ID" => "7",
        );
        $arPropertyFilter = array(
            "LOGIC" => "OR"
        );
        if($_GET['filter_hit'] == 'Y'){
            $arPropertyFilter[] = array("PROPERTY_YAVLYAETSI_VALUE" => "популярным");
        }
        if($_GET['filter_new'] == 'Y'){
            $arPropertyFilter[] = array("PROPERTY_YAVLYAETSI_VALUE" => "новинкой");
        }
        if($_GET['filter_sale'] == 'Y'){
            $arPropertyFilter[] = array("PROPERTY_YAVLYAETSI_VALUE" => "акцией");
        }
        $arrFilter[] = $arPropertyFilter;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question