Answer the question
In order to leave comments, you need to log in
How to select 1 element in the infoblock by element property in bitrix?
You need to select 1 element whose field value = 5200014561. Property code BILL. What's wrong? With this code, it displays everything.
$dbData = CIBlockElement::getList(
array(),
[
'IBLOCK_ID' => 230,
'PROPERTY_BILL' => "5200014561",
],
false, false,
['ID', 'IBLOCK_ID', 'PROPERTY_BILL']
);
while ($res = $dbData->GetNextElement()) {
echo "<pre>";
print_r($res->GetProperties());
echo "</pre>";
}
Answer the question
In order to leave comments, you need to log in
I tried it already, it didn't help, although according to the docks exactly as you described it should work.
$arFilter = Array("IBLOCK_ID"=>230, "PROPERTY_BILL" => "5200014561");
$arSelect = Array('ID', 'IBLOCK_ID');
$res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, array(), $arSelect);
while($ob = $res->GetNextElement()){
$arFields = $ob->GetFields();
echo "<pre>";
print_r($arFields);
echo "</pre>";
}
Do you have this value in the infoblock only for one element in the property or not? if not, then it will display all the elements
$sort = ['ID' => 'ASC'];
$filter = ['IBLOCK_ID' => 230, '=PROPERTY_BILL' => '5200014561']; //тут число еще а не строку попробуйте, хотя это не должно никак повлиять
$select = ['ID', 'IBLOCK_ID', 'PROPERTY_BILL'];
//если элементов несколько с таким значением - это выведет первый
$nTopCount = false;
//$nTopCount = ['nTopCount' => 1]; можно еще так ограничить
$el = CIBlockElement::GetList($sort, $filter, false, $nTopCount, $select)->Fetch();
var_dump($el);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question