public function getData() { if (!isset($this->_data)) { $shop = $this->getShop(); $lang = $this->getLang(); $root_category = (int) $this->getRootCategory(); if ($this->_full_tree) { $this->setData(BlogCategory::getNestedCategories($root_category, $lang, false, null, $this->useShopRestriction())); $this->setDataSearch(BlogCategory::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } elseif ($this->_children_only) { if (empty($root_category)) { $root_category = BlogCategory::getRootCategory(); $root_category = $root_category['id_smart_blog_category']; } $categories = array(); $categories[$root_category] = BlogCategory::getChildren($root_category, $lang, false, $shop->id); $children = $this->fillTree($categories, $root_category); $this->setData($children); } else { if (empty($root_category)) { $root_category = BlogCategory::getRootCategory(); $root_category = $root_category['id_smart_blog_category']; } $new_selected_categories = array(); $selected_categories = $this->getSelectedCategories(); $categories[$root_category] = BlogCategory::getChildren($root_category, $lang, false); foreach ($selected_categories as $selected_category) { $category = new BlogCategory($selected_category, $lang, $shop->id); $new_selected_categories[] = $selected_category; $parents = $category->getParentsCategories($lang); foreach ($parents as $value) { $new_selected_categories[] = $value['id_category']; } } $new_selected_categories = array_unique($new_selected_categories); foreach ($new_selected_categories as $selected_category) { $current_category = BlogCategory::getChildren($selected_category, $lang, false, $shop->id); if (!empty($current_category)) { $categories[$selected_category] = $current_category; } } $tree = BlogCategory::getCategoryInformations(array($root_category), $lang); $children = $this->fillTree($categories, $root_category); if (!empty($children)) { $tree[$root_category]['children'] = $children; } $this->setData($tree); $this->setDataSearch(BlogCategory::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } } return $this->_data; }