Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
helper.php
1<?php
2
4
6
12final class Helper
13{
23 public static function fillNormNameColumn($startId = 0, $timeout = 0, $limit = 100)
24 {
26 $startTime = microtime(false);
27 $normalizers = [];
28 $glParams = [
29 'filter' => [
30 '>=ID' => $startId,
31 '=NAME_NORM' => false
32 ]
33 ];
34
35 if($limit > 0)
36 {
37 $glParams['limit'] = $limit;
38 }
39
40 $res = Name\LocationTable::getList($glParams);
41 $lastId = $startId;
42
43 while($row = $res->fetch())
44 {
45 if(!isset($normalizers[$row['LANGUAGE_ID']]))
46 {
47 $normalizers[$row['LANGUAGE_ID']] = \Bitrix\Sale\Location\Normalizer\Builder::build($row['LANGUAGE_ID']);
48 }
49
50 Name\LocationTable::update(
51 $row['ID'],
52 [
53 'NAME_NORM' => $normalizers[$row['LANGUAGE_ID']]->normalize($row['NAME'])
54 ]
55 );
56
57 $lastId = $row['ID'];
58
59 if($timeout && $startTime + $timeout >= microtime(false))
60 {
61 break;
62 }
63 }
64
65 return $lastId;
66 }
67}