Answer the question
In order to leave comments, you need to log in
Bitrix selection from infoblock, how to filter by multi-property?
PROPERTY_HIT - list type property, contains New, Promotion, Hit, etc.
I filter the elements by the value "New" so that these elements are not in the selection
$arFilter = Array(
"IBLOCK_ID"=>$IBLOCK_ID,
"ACTIVE"=>"Y",
">=DATE_CREATE"=>date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT")), mktime(0,0,0,$date)),
"!PROPERTY_HIT_VALUE"=>array("Новинка"),
);
$productQuery = CIBlockElement::GetList(Array(), $arFilter,false,false, Array("ID","IBLOCK_ID","DATE_CREATE","NAME","PROPERTY_HIT"));
array(14) {
["ID"]=>
string(5) "34255"
["~ID"]=>
string(5) "34255"
["IBLOCK_ID"]=>
string(2) "53"
["~IBLOCK_ID"]=>
string(2) "53"
["DATE_CREATE"]=>
string(19) "14.08.2018 14:45:58"
["~DATE_CREATE"]=>
string(19) "14.08.2018 14:45:58"
["NAME"]=>
string(4) "test"
["~NAME"]=>
string(4) "test"
["PROPERTY_HIT_VALUE"]=>
string(10) "Акция"
["~PROPERTY_HIT_VALUE"]=>
string(10) "Акция"
["PROPERTY_HIT_ENUM_ID"]=>
string(2) "91"
["~PROPERTY_HIT_ENUM_ID"]=>
string(2) "91"
["PROPERTY_HIT_VALUE_ID"]=>
string(6) "224294"
["~PROPERTY_HIT_VALUE_ID"]=>
string(6) "224294"
}
Answer the question
In order to leave comments, you need to log in
There are several ways to do this. As the user Maxim
suggested, you can translate the method of storing properties into a separate table. This will increase the speed of the search and fix this misunderstanding left over from the infoblocks of version 1.
If you don’t want to do anything, but want everything to work, then you can use SubQuery in CIblockElement
\Bitrix\Main\Loader::IncludeModule('iblock');
$arFilter = Array(
"IBLOCK_ID" => 2,
"ACTIVE" => "Y",
"!ID" => \CIBlockElement::SubQuery("PROPERTY_HIT", array(
"IBLOCK_ID" => 2,
"PROPERTY_HIT_VALUE" => "Новинка",
))
);
$productQuery = \CIBlockElement::GetList(
[],
$arFilter,
false,
false,
[
"ID",
"IBLOCK_ID",
"NAME",
"PROPERTY_HIT"
]
);
while( $arElement = $productQuery->fetch() )
{
echo "<pre>";
var_dump($arElement);
echo "</pre>";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question