L
L
link08022013-12-25 22:33:25
PHP
link0802, 2013-12-25 22:33:25

Multiple binding to elements and filtering via GetList

There is a property which is a binding to elements. (eg PROPERTY_GOAL). It is necessary to display all elements in the properties of which there is a binding to a certain element, but there is no binding to another element, using CIBlockElement::GetList. The ID of the tethered blocks by which to filter is known.
How to correctly set $arFilter? So far, the maximum has reached:

$arFilter = array(
"IBLOCK_ID"=>$blocks, 
"IBLOCK_SECTION_ID"=>$sectionIDS, 
"PROPERTY_GOAL.ID"=>466,  //если в свойстве GOAL  указана привязка к элементу с ID 466
"!PROPERTY_GOAL.ID"=>462, // и нет привязка к элементу с ID 462, то данный элемент подходит и попадает в $arResult 
"PROPERTY_RECOMEND_VALUE"=>"да",
"ACTIVE_DATE"=>"Y", 
"ACTIVE"=>"Y");

Such filtering works, but I would like to be sure that it works 100% correctly. I would be glad for any help / hints, etc.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Misha Vasilyev, 2013-12-26
@vasilyev

I would like you to tell me exactly where you are not sure, because the code is correct and, as you say, it works.
On the other hand, if I understand correctly, you can simply use the "PROPERTY_GOAL_VALUE" and "!PROPERTY_GOAL_VALUE" constructs (if they work correctly with a multiple parameter value). It seems to me that since the binding goes anyway by ID (PROPERTY_GOAL_VALUE will contain exactly the IDs of the elements to which it is attached), then it makes no sense to pull out the ID from the bound element.

A
Alexey, 2016-03-15
@rixaman

Filter with complex logic
Under the call parameters in the documentation.
More or less like this.
$arFilter = array(
"IBLOCK_ID"=>$blocks,
"IBLOCK_SECTION_ID"=>$sectionIDS,
array(
"LOGIC" => "AND",
array("PROPERTY_GOAL.ID" => 466),
array("!PROPERTY_GOAL. ID" => 462),
),
"PROPERTY_RECOMEND_VALUE"=>"yes",
"ACTIVE_DATE"=>"Y",
"ACTIVE"=>"Y");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question