Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/catalog/lib/product/ |
Upload File : |
<?php namespace Bitrix\Catalog\Product; use Bitrix\Main, Bitrix\Iblock, Bitrix\Catalog; /** * Class Viewed * Provides various useful methods for viewed products. * * @package Bitrix\Catalog\Product */ class Viewed { /** * Return parent section id for need section depth. * * @param int $sectionId Section id. * @param int $depth Parent section depth. * @return int|null * @throws Main\ArgumentException */ public static function getParentSection($sectionId, $depth) { $sectionId = (int)$sectionId; $depth = (int)$depth; if ($sectionId <= 0 || $depth <= 0) return null; $section = Iblock\SectionTable::getList(array( 'select' => array('ID', 'IBLOCK_ID', 'LEFT_MARGIN', 'RIGHT_MARGIN', 'DEPTH_LEVEL'), 'filter' => array('=ID' => $sectionId) ))->fetch(); if (empty($section)) return null; $section['DEPTH_LEVEL'] = (int)$section['DEPTH_LEVEL']; if ($section['DEPTH_LEVEL'] < $depth) return null; if ($section['DEPTH_LEVEL'] == $depth) return (int)$section['ID']; $parentSection = Iblock\SectionTable::getList(array( 'select' => array('ID'), 'filter' => array( '=IBLOCK_ID' => $section['IBLOCK_ID'], '<=LEFT_MARGIN' => $section['LEFT_MARGIN'], '>=RIGHT_MARGIN' => $section['RIGHT_MARGIN'], '=DEPTH_LEVEL' => $depth ) ))->fetch(); if (!empty($parentSection)) return (int)$parentSection['ID']; return null; } }