Answer the question
In order to leave comments, you need to log in
How to filter elements by property ID?
Hello !
There is a custom property (binding to elements) that stores the diet ID. The diets themselves are elements in the infoblock, which has properties (multiple binding to elements) for the days of the week. That is, a diet is selected in the user's card, in which, by the days of the week, there is a link to elements in another infoblock (dishes). It is necessary to select all elements (dishes) in accordance with the user's chosen diet. Right now I have this option, but it selects everything, without filtering by diet ID:
$arFilter = Array(
"IBLOCK_ID" => 19,
"ACTIVE" => "Y",
"!ID" => \CIBlockElement::SubQuery("PROPERTY_MON", array(
"IBLOCK_ID" => 19,
"ID"=>$b // $b=тут хранится ID диеты.
))
);
$productQuery = \CIBlockElement::GetList(
[],
$arFilter,
false,
false,
[
"ID",
"IBLOCK_ID",
"NAME",
"PROPERTY_MON"
]
);
while( $arElement = $productQuery->fetch() )
{
echo "<pre>";
var_dump($arElement);
echo "</pre>";
}
Answer the question
In order to leave comments, you need to log in
It seems to me that you are too clever with the filter, just try
$arFilter = Array(
"IBLOCK_ID" => 19,
"ACTIVE" => "Y",
"PROPERTY_<b>код свойства</b>" => $b
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question