66 public static function catalogSearch($query =
null, $type = self::TYPE_CATALOG_ALL, $iblock =
null, $siteId =
null)
72 \Bitrix\Landing\Hook::setEditMode(
true);
73 $settings = \Bitrix\Landing\Hook\Page\Settings::getDataForSite(
76 $iblockId = $settings[
'IBLOCK_ID'];
83 if (!Loader::includeModule(
'iblock'))
85 $publicResult->setResult([]);
93 'IBLOCK_ID' => $iblockId,
96 array_map(
function($fragment) {
97 return [
'%NAME' => trim($fragment)];
98 }, explode(
' ', trim($query)))
104 $type === self::TYPE_CATALOG_ALL ||
105 $type === self::TYPE_CATALOG_ELEMENT)
109 $navParams = [
'nTopCount' => 50];
111 'ID',
'NAME',
'IBLOCK_SECTION_ID',
'DETAIL_PICTURE'
114 $result = \CIBlockElement::getList(
115 $order, $filter, $groupBy, $navParams, $select
117 while ($item = $result->fetch())
120 static::makeCatalogEntityNavChain(
121 $item[
'IBLOCK_SECTION_ID'],
125 'name' => $item[
'NAME'],
127 'image' => \CFile::getPath($item[
'DETAIL_PICTURE']),
136 $type === self::TYPE_CATALOG_ALL ||
137 $type === self::TYPE_CATALOG_SECTION
142 'ID',
'NAME',
'IBLOCK_SECTION_ID',
'DETAIL_PICTURE'
145 'IBLOCK_ID' => $iblockId,
'%NAME' => trim($query)
149 $sectResult = \CIBlockSection::GetList($order, $filter, $count, $select);
150 while ($item = $sectResult->Fetch())
153 static::makeCatalogEntityNavChain(
154 $item[
'IBLOCK_SECTION_ID'],
158 'name' => trim($item[
'NAME']),
163 'chain' => !empty($chain) ? $chain : [
'/']
169 $publicResult->setResult($data);
171 return $publicResult;
206 $entityId = (int)$entityId;
208 if (Loader::includeModule(
'iblock'))
213 $res = \CIBlockElement::getList(
217 'CHECK_PERMISSIONS' =>
'Y'
224 'ID',
'NAME',
'DETAIL_PICTURE',
'IBLOCK_SECTION_ID'
230 $res = \CIBlockSection::getList(
234 'CHECK_PERMISSIONS' =>
'Y'
238 'ID',
'NAME',
'IBLOCK_SECTION_ID'
245 if ($entity = $res->fetch())
248 static::makeCatalogEntityNavChain(
249 $entity[
'IBLOCK_SECTION_ID'],
253 'id' => $entity[
'ID'],
254 'name' => $entity[
'NAME'],
255 'sectionId' => $entity[
'IBLOCK_SECTION_ID'],
256 'image' => $isElement
257 ? \CFile::getPath($entity[
'DETAIL_PICTURE'])
260 'subType' => $entityType,
330 static $urls = array();
331 static $settings = array();
333 $elementId = (int)$elementId;
334 $key = (string)$urlType .
'_' . $elementId;
336 if (isset($urls[$key]))
341 if (!\
Bitrix\Main\Loader::includeModule(
'iblock'))
346 if (empty($settings))
348 \Bitrix\Landing\Hook::setEditMode(
true);
349 $settings = \Bitrix\Landing\Hook\Page\Settings::getDataForSite();
352 $urls[$key] =
'#system_catalog';
353 $iblockId = $settings[
'IBLOCK_ID'];
356 if ($urlType ==
'detail' || $urlType ==
'element')
359 $res = \Bitrix\Iblock\ElementTable::getList(array(
361 'ID',
'CODE',
'IBLOCK_SECTION_ID'
365 'IBLOCK_ID' => $iblockId
368 if (!($element = $res->fetch()))
373 $urls[$key] .=
'item/' . $element[
'CODE'] .
'/';
375 elseif ($urlType ==
'section')
377 $res = \CIBlockSection::getNavChain(
381 while ($row = $res->fetch())
383 $urls[$key] .= $row[
'CODE'] .
'/';