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/wbs24.ozonapinew/lib/Products/ |
Upload File : |
<?php namespace Wbs24\Ozonapinew\Products; use Wbs24\Ozonapinew\{ Wrappers }; /** * Класс для работы с разделами товаров Битрикс */ class Sections { public function __construct($objects = []) { $this->wrappers = new Wrappers($objects); } public function getSubSections($parentSectionIds) { if (!$parentSectionIds) return []; $subSectionIds = []; $result = $this->wrappers->CIBlockSection->GetList( ["SORT" => "ASC"], ["SECTION_ID" => $parentSectionIds, "ACTIVE" => "Y"], false, ["ID"], ); while ($section = $result->Fetch()) { $subSectionIds[] = $section['ID']; } if ($subSectionIds) $subSectionIds = array_merge($subSectionIds, $this->getSubSections($subSectionIds)); return $subSectionIds; } public function getAllSections($iblockId) { $sections = []; $result = $this->wrappers->CIBlockSection->GetList( ["SORT" => "ASC"], ["IBLOCK_ID" => $iblockId], false, ["ID", "NAME", "IBLOCK_SECTION_ID", "ACTIVE"], ); while ($section = $result->Fetch()) { $sections[] = [ 'id' => $section['ID'], 'active' => $section['ACTIVE'], 'name' => '['.$section['ID'].'] '.$section['NAME'], 'parent' => $section['IBLOCK_SECTION_ID'], ]; } return $sections; } public function getSectionTreeFromList($sectionList, $parent = 0) { $sectionsAsTree = []; foreach ($sectionList as $v) { if ($v['parent'] != $parent) continue; $sectionsAsTree[] = [ 'id' => $v['id'], 'active' => $v['active'], 'name' => $v['name'], 'items' => $this->getSectionTreeFromList($sectionList, $v['id']), ]; } return $sectionsAsTree; } }