1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
iblockelementfulltextindex.php
См. документацию.
1<?php
2namespace Bitrix\Iblock\Update;
3
4use Bitrix\Crm\Product\Catalog;
5use Bitrix\Iblock\ElementTable;
6use Bitrix\Iblock\FullIndex\FullText;
7use Bitrix\Iblock\IblockTable;
8use Bitrix\Main\Loader;
9use Bitrix\Main\Localization\Loc;
10use Bitrix\Main\Update\Stepper;
11
13{
14 protected const ELEMENT_LIMIT = 50;
15
16 protected static $moduleId = 'iblock';
17
18 public function execute(array &$option): bool
19 {
20 $option["count"] ??= ElementTable::getCount([
21 'IBLOCK.FULLTEXT_INDEX' => 'Y',
22 ]);
23 $option["steps"] ??= 0;
24 $option["lastElementId"] ??= 0;
25 $option["iblockIds"] ??= $this->prepareIblockIds();
26
27 if (empty($option["iblockIds"]))
28 {
29 return self::FINISH_EXECUTION;
30 }
31
32 $elementData = ElementTable::getList([
33 'limit' => self::ELEMENT_LIMIT,
34 'select' => ['ID', 'IBLOCK_ID', 'SEARCHABLE_CONTENT'],
35 'filter' => [
36 '>ID' => (int)$option["lastElementId"],
37 '@IBLOCK_ID' => $option["iblockIds"],
38 ],
39 'order' => ['ID' => 'ASC'],
40 ]);
41
42 $elementCount = 0;
43 while ($element = $elementData->fetch())
44 {
45 $elementId = $element["ID"];
46 $iblockId = $element['IBLOCK_ID'];
47 $searchableContent = $element['SEARCHABLE_CONTENT'];
48 $option["lastElementId"] = $elementId;
49
50 $searchIndexParams = [
51 'ELEMENT_ID' => $elementId,
52 'SEARCH_CONTENT' => $searchableContent,
53 ];
54
55 FullText::update($iblockId, $elementId, $searchIndexParams);
56
57 $elementCount++;
58 }
59
60 $option["steps"] += $elementCount;
61
62 return $elementCount === 0 ? self::FINISH_EXECUTION : self::CONTINUE_EXECUTION;
63 }
64
65 public static function getTitle(): string
66 {
67 return Loc::getMessage('IBLOCK_ELEMENT_SEARCHABLE_CONTENT_TRANSFER');
68 }
69
70 private static function prepareIblockIds(): array
71 {
72 if (!Loader::includeModule('crm'))
73 {
74 return [];
75 }
76
77 $iblockIds = [];
78
79 $catalogProductId = Catalog::getDefaultId();
80 $obIBlock = new \CAllIBlock();
81
82 if (isset($catalogProductId))
83 {
84 $obIBlock->Update($catalogProductId, ['FULLTEXT_INDEX' => 'Y']);
85 $iblockIds[] = $catalogProductId;
86 }
87
88 $catalogOffersId = Catalog::getDefaultOfferId();
89
90 if (isset($catalogOffersId))
91 {
92 $obIBlock->Update($catalogOffersId, ['FULLTEXT_INDEX' => 'Y']);
93 $iblockIds[] = $catalogOffersId;
94 }
95
96 return $iblockIds;
97 }
98}
static includeModule($moduleName)
Определения loader.php:67
static getList(array $parameters=array())
Определения datamanager.php:431
static getCount($filter=array(), array $cache=array())
Определения datamanager.php:516
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$iblockId
Определения iblock_catalog_edit.php:30
$option
Определения options.php:1711