1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
section.php
См. документацию.
1<?php
2
3namespace Bitrix\Iblock\Copy\Stepper;
4
5use Bitrix\Main\Loader;
6use Bitrix\Iblock\ElementTable;
7use Bitrix\Iblock\SectionTable;
8
9class Section extends Entity
10{
11 protected $queueName = "SectionGroupQueue";
12 protected $checkerName = "SectionGroupChecker_";
13 protected $baseName = "SectionGroupStepper_";
14 protected $errorName = "SectionGroupError_";
15
24 public function execute(array &$option)
25 {
26 if (!Loader::includeModule(self::$moduleId))
27 {
28 return false;
29 }
30
31 try
32 {
33 $queue = $this->getQueue();
34 $this->setQueue($queue);
35 $queueOption = $this->getQueueOption();
36 if (empty($queueOption))
37 {
38 $this->deleteQueueOption();
39 return !$this->isQueueEmpty();
40 }
41
42 $sectionId = ($queueOption["sectionId"] ?: 0);
43 $copiedSectionId = ($queueOption["copiedSectionId"] ?: 0);
44 $errorOffset = ($queueOption["errorOffset"] ?: 0);
45
46 $limit = 5;
47 $offset = $this->getOffset($copiedSectionId) + $errorOffset;
48
49 $enumRatio = ($queueOption["enumRatio"] ?: []);
50 $sectionsRatio = ($queueOption["sectionsRatio"] ?: []);
51 $mapIdsCopiedElements = ($queueOption["mapIdsCopiedElements"] ?: []);
52
53 if ($sectionId)
54 {
55 list($elementIds, $selectedRowsCount) = $this->getElementIds($sectionId, $limit, $offset);
56
57 $elementCopier = $this->getElementCopier();
58 $containerCollection = $this->getContainerCollection($elementIds, $sectionsRatio, $enumRatio);
59 $result = $elementCopier->copy($containerCollection);
60 if (!$result->isSuccess())
61 {
62 $queueOption["errorOffset"] += $this->getErrorOffset($elementCopier);
63 }
64
65 $mapIdsCopiedElements = $elementCopier->getMapIdsCopiedEntity() + $mapIdsCopiedElements;
66 $queueOption["mapIdsCopiedElements"] = $mapIdsCopiedElements;
67 $this->saveQueueOption($queueOption);
68
69 if ($selectedRowsCount < $limit)
70 {
71 $this->deleteQueueOption();
72 return !$this->isQueueEmpty();
73 }
74 else
75 {
76 $option["steps"] = $offset;
77 return true;
78 }
79 }
80 else
81 {
82 $this->deleteQueueOption();
83 return !$this->isQueueEmpty();
84 }
85 }
86 catch (\Exception $exception)
87 {
88 $this->writeToLog($exception);
89 $this->deleteQueueOption();
90 return false;
91 }
92 }
93
94 private function getElementIds(int $sectionId, int $limit, int $offset): array
95 {
96 $section = SectionTable::getRow([
97 'select' => [
98 'ID',
99 'IBLOCK_ID',
100 ],
101 'filter' => [
102 '=ID' => $sectionId,
103 ],
104 ]);
105
106 if ($section === null)
107 {
108 return [[], 0];
109 }
110
111 $elementIds = [];
113 'select' => [
114 'ID',
115 ],
116 'filter' => [
117 '=IBLOCK_ID' => (int)$section['IBLOCK_ID'],
118 '=IBLOCK_SECTION_ID' => (int)$section['ID'],
119 ],
120 'order' => [
121 'ID' => 'ASC',
122 ],
123 'limit' => $limit,
124 'offset' => $offset,
125 ]);
126 while ($row = $iterator->fetch())
127 {
128 $elementIds[] = $row['ID'];
129 }
130 unset($row, $iterator);
131
132 return [$elementIds, count($elementIds)];
133 }
134
135 private function getOffset(int $copiedSectionId): int
136 {
137 $section = SectionTable::getRow([
138 'select' => [
139 'ID',
140 'IBLOCK_ID',
141 ],
142 'filter' => [
143 '=ID' => $copiedSectionId,
144 ],
145 ]);
146
147 if ($section === null)
148 {
149 return 0;
150 }
151
153 '=IBLOCK_ID' => (int)$section['IBLOCK_ID'],
154 '=IBLOCK_SECTION_ID' => (int)$section['ID'],
155 ]);
156 }
157}
saveQueueOption(array $data)
Определения entity.php:102
getContainerCollection($elementIds, array $sectionsRatio, array $enumRatio, $targetIblockId=0)
Определения entity.php:16
setQueue(array $queue)
Определения entity.php:86
getErrorOffset(EntityCopier $elementCopier)
Определения entity.php:55
execute(array &$option)
Определения section.php:24
static includeModule($moduleName)
Определения loader.php:67
static getRow(array $parameters)
Определения datamanager.php:398
static getList(array $parameters=array())
Определения datamanager.php:431
static getCount($filter=array(), array $cache=array())
Определения datamanager.php:516
writeToLog(\Exception $exception)
Определения stepper.php:404
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$option
Определения options.php:1711
$iterator
Определения yandex_run.php:610