Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
search.php
1<?php
3
6
13class Search
14{
15 protected static $catalogList = array();
16
23 public static function onBeforeIndex($fields)
24 {
25 if (!isset($fields['MODULE_ID']) || $fields['MODULE_ID'] != 'iblock')
26 return $fields;
27 if (empty($fields['PARAM2']))
28 return $fields;
29
30 if (!isset(self::$catalogList[$fields['PARAM2']]))
31 {
32 self::$catalogList[$fields['PARAM2']] = false;
33 $catalog = Catalog\CatalogIblockTable::getList(array(
34 'select' => array('IBLOCK_ID'),
35 'filter' => array('=IBLOCK_ID' => $fields['PARAM2'])
36 ))->fetch();
37 if (!empty($catalog))
38 self::$catalogList[$fields['PARAM2']] = $catalog['IBLOCK_ID'];
39 unset($catalog);
40 }
41
42 if (!empty(self::$catalogList[$fields['PARAM2']]) && isset($fields['ITEM_ID']))
43 {
44 $fields['PARAMS']['iblock_section'] = array();
45 if (mb_strpos($fields['ITEM_ID'], 'S') === false)
46 {
47 $sections = Iblock\SectionElementTable::getList(array(
48 'select' => array('IBLOCK_SECTION_ID'),
49 'filter' => array('=IBLOCK_ELEMENT_ID' => $fields['ITEM_ID'], '=ADDITIONAL_PROPERTY_ID' => null)
50 ));
51 while ($section = $sections->fetch())
52 {
54 $nav = \CIBlockSection::getNavChain($fields['PARAM2'], $section['IBLOCK_SECTION_ID'], array('ID'));
55 while ($chain = $nav->fetch())
56 $fields['PARAMS']['iblock_section'][$chain['ID']] = $chain['ID'];
57 unset($chain, $nav);
58 }
59 unset($section, $sections);
60 }
61 else
62 {
64 $nav = \CIBlockSection::getNavChain($fields['PARAM2'], preg_replace('#[^0-9]+#', '', $fields["ITEM_ID"]), array('ID'));
65 while ($chain = $nav->fetch())
66 $fields['PARAMS']['iblock_section'][$chain['ID']] = $chain['ID'];
67 unset($chain, $nav);
68 }
69 if (!empty($fields['PARAMS']['iblock_section']))
70 $fields['PARAMS']['iblock_section'] = array_values($fields['PARAMS']['iblock_section']);
71 }
72 return $fields;
73 }
74}
static onBeforeIndex($fields)
Definition search.php:23