I
I
Ivan Anikin2020-08-26 13:32:57
1C-Bitrix
Ivan Anikin, 2020-08-26 13:32:57

Why doesn't "group" work in Bitrix\Sale\PropertyValueCollection::getList?

Trying to get the number of orders made for each INN:

$inn = Bitrix\Sale\PropertyValueCollection::getList([
            'order' => [],
            'select' => ['*'],
            'group' => ['COUNT' => 'VALUE'],
            'filter' => [
                '!ORDER_ID' => false,
                'CODE' => "INN"
            ]
        ])->fetchAll();


But as a result, an array arrives where VALUEs are duplicated and there is no 'COUNT' field.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-08-26
@randomizex

$inn = Bitrix\Sale\PropertyValueCollection::getList([
  'order' => [],
  'select' => ['VALUE', 'COUNT'],
  'filter' => [
    '!ORDER_ID' => false,
    '=CODE' => 'INN'
  ],
  'runtime' => [
    new \Bitrix\Main\Entity\ExpressionField('COUNT', 'COUNT(*)')
  ]
])->fetchAll();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question