bitrix24-php-sdk icon indicating copy to clipboard operation
bitrix24-php-sdk copied to clipboard

batch list lost elements if use order arguments

Open mesilov opened this issue 1 year ago • 0 comments

        $greaterThanDefaultPageSize = 120;
        $originatorId = Uuid::v7()->toRfc4122();
        // add contacts
        $contacts = [];
        for ($i = 0; $i < $greaterThanDefaultPageSize; $i++) {
            $contacts[] = [
                'fields' => [
                    'NAME' => 'name-' . $i,
                    'ORIGINATOR_ID' => $originatorId,
                    'ORIGIN_ID' => $i
                ]
            ];
        }
        $cnt = 0;
        foreach ($this->batch->addEntityItems('crm.contact.add', $contacts) as $addedContactResult) {
            $this->createdContactIds[] = $addedContactResult->getResult()[0];
            $cnt++;
        }
        $this->assertEquals(count($contacts), $cnt);
        $this->assertEquals(count($contacts), $this->serviceBuilder->getCRMScope()->contact()->countByFilter([
            'ORIGINATOR_ID' => $originatorId
        ]));

        // test batch with order
        $readContactsId = [];
        foreach ($this->batch->getTraversableList('crm.contact.list',
            ['ORIGIN_ID' => 'DESC'],
            [
                'ORIGINATOR_ID' => $originatorId
            ],
            [
                'ID',
                'NAME',
                'ORIGINATOR_ID',
                'ORIGIN_ID'
            ],
        ) as $cnt => $itemContact) {
            $readContactsId[] = $itemContact['ID'];
            print($itemContact['ID'] . ' | ' . $itemContact['ORIGIN_ID'] . PHP_EOL);
        }
        $this->assertCount($greaterThanDefaultPageSize, $readContactsId);

mesilov avatar Jun 30 '24 12:06 mesilov