id = $categoryId ?? $category->get('ID'); $xmlCategory->name = $category->get('NAME'); $xmlCategory->parentId = $categoryId ? 0 : $category->get('IBLOCK_SECTION_ID'); $xmlCategory->picture = $picture; } catch (ArgumentException | SystemException $exception) { return null; } return $xmlCategory; } }