23 public function execute(array &$result, ?
int $siteId =
null): bool
36 $globalFilter[
'SITE_ID'] = $siteId;
46 'filter' => $globalFilter
48 if ($row = $res->fetch())
50 $result[
'count'] = $row[
'CNT'];
56 'ID',
'TITLE',
'CODE',
'ACTIVE',
'DELETED',
'SITE_ID'
58 'filter' => $globalFilter,
63 while ($page = $res->fetch())
67 $resFolder = Folder::add([
68 'SITE_ID' => $page[
'SITE_ID'],
69 'TITLE' => $page[
'TITLE'],
70 'CODE' => $page[
'CODE'],
71 'ACTIVE' => $page[
'ACTIVE'],
72 'DELETED' => $page[
'DELETED']
74 if ($resFolder->isSuccess())
76 $folderId = $resFolder->getId();
80 foreach ($resFolder->getErrors() as $error)
82 if ($error->getCode() ===
'FOLDER_IS_NOT_UNIQUE')
84 $resFolder = Folder::getList([
89 'SITE_ID' => $page[
'SITE_ID'],
91 '=CODE' => $page[
'CODE']
94 if ($rowFolder = $resFolder->fetch())
96 $folderId = $rowFolder[
'ID'];
105 Folder::update($folderId, [
106 'INDEX_ID' => $page[
'ID']
108 LandingTable::update($page[
'ID'], [
110 'FOLDER_ID' => $folderId
112 Debug::log(
'FU:LandingTable::update', var_export([
115 'FOLDER_ID' => $folderId
123 'FOLDER_ID' => $page[
'ID'],
128 while ($rowPage = $resPage->fetch())
130 LandingTable::update($rowPage[
'ID'], [
131 'FOLDER_ID' => $folderId
133 Debug::log(
'FU:LandingTable::update', var_export([
134 'ID' => $rowPage[
'ID'],
135 'FOLDER_ID_OLD' => $rowPage[
'FOLDER_ID'],
136 'FOLDER_ID' => $folderId
144 if ($finished && !$siteId)