Answer the question
In order to leave comments, you need to log in
How to “optimally” calculate the number of elements by property in Bitrix?
Good afternoon.
There is "Infoblock 2.0", with property "source" type list (list in $arSource), about 100k+ elements.
It is necessary to count the number of elements for each property from the list.
$arSource = ["google","yandex","mail","avito", "еще 10 элементов"];
foreach ($arSource as $s)
$uCnt[$s] = \Bitrix\Iblock\Elements\ElementApivatsmtsTable::getList(['filter' => ['source.VALUE'=>$s], 'count_total' => 1])->getCount();
Answer the question
In order to leave comments, you need to log in
Make a query with grouping and counting. Example:
\Bitrix\Iblock\Elements\ElementCatalogTable::getList([
"select" => [
"BRAND_VALUE" => "BRAND.VALUE",
"COUNT",
],
"filter" => [
"!BRAND.VALUE" => false
],
"group" => [
"BRAND.VALUE"
],
"runtime" => [
new \Bitrix\Main\ORM\Fields\ExpressionField('COUNT', 'COUNT(*)' )
]
])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question