R
R
Roman Govorov2021-09-03 16:06:28
Bitrix24
Roman Govorov, 2021-09-03 16:06:28

How to unload large amounts of Bitrix24 data in PHP?

There is an example from Bitrix: https://dev.1c-bitrix.ru/rest_help/rest_sum/start.php but here I don't understand how to apply it to my task.

I want to import 1500 new companies, but before importing, check if this company exists in the bitr or not by the TIN field.
I do it through callBatch but there is a maximum of 50 results returned..

foreach ($allCompany as $k => $v) {
            debug($v['inn']);
            if (!empty($v['inn'])){
                $request[$k . 'crm.company.list'] = [
                    'method' => 'crm.company.list',
                    'params' => [
                        'order' => ['ID' => 'ASC'],
                        'filter' => [
                            'UF_CRM_5F' => $v['inn'],
                        ],
                        'select' => [
                            'ID',
                        ],
                    ]
                ];
            }
        }
        $request = CRest::callBatch($request);


How to go over all the companies and compare them with 1500 new ones and to bypass the limit or do it somehow according to the Bitrix law ....?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2021-09-20
@gromdron

How to go over all the companies and compare them with 1500 new ones and to bypass the limit or do it somehow according to the Bitrix law ....?

batch request aggregation of 50 requests.
Each list query can return no more than 50 items.
Thus, 2500 elements can be unloaded per 1 batch.
Those. you formalize the first batch by operating the start method (start=0, start=1, etc. up to start=49).
It is easier to compare existence in a local cache, i.e. get everything, find discrepancies and generate batches for creating/updating companies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question