Site Map

', $parent_group_end_string = '', $child_start_string = '
  • ', $child_end_string = '
  • ', $spacer_string = '', $spacer_multiplier = 1, $group_categories_array = array(); function osC_CategoryTree($load_from_database = true) { global $languages_id, $customer_group_id, $group_categories_array; if($customer_group_id > 0) { $group_categories_query = tep_db_query("select c.categories_id from " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_GROUPS . " pg, " . TABLE_PRODUCTS_TO_CATEGORIES . ' p2c' . " where c.categories_id = p2c.categories_id and p2c.products_id = pg.products_id and pg.customers_group_id = " . $customer_group_id . " order by c.parent_id, c.sort_order"); while ($group_categories = tep_db_fetch_array($group_categories_query)) { $group_categories_array[] = $group_categories[categories_id]; } } $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id, c.tabular_listing from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.parent_id, c.sort_order, cd.categories_name"); $this->data = array(); while ($categories = tep_db_fetch_array($categories_query)) { // Ultimate SEO URLs compatibility - Chemo # initialize array container for parent_id $p = array(); tep_get_parent_categories($p, $categories['parent_id']); # For some reason it seems to return in reverse order so reverse the array $p = array_reverse($p); # Implode the array to get the parent category path $cID = (implode('_', $p) ? implode('_', $p) . '_' . $categories['parent_id'] : $categories['parent_id']); # initialize array container for category_id $c = array(); tep_get_parent_categories($c, $categories['categories_id']); # For some reason it seems to return in reverse order so reverse the array $c = array_reverse($c); # Implode the array to get the full category path $id = (implode('_', $c) ? implode('_', $c) . '_' . $categories['categories_id'] : $categories['categories_id']); $this->data[$cID][$id] = array('name' => $categories['categories_name'], 'count' => 0, 'tabular' => $categories['tabular_listing'] ); } // eof While loop } //eof Function // estores added 13052006 function get_products_in_category($category_id) { global $languages_id; // fixed bug with function tep_get_category_id_from_path - estores 13032008 $product_info_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc, " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.categories_id = " . tep_get_category_id_from_path($category_id) . " and p.products_status = '1' and pd.products_id = p.products_id and pd.products_id = ptc.products_id and ptc.categories_id = cd.categories_id and pd.language_id = '" . (int)$languages_id . "'"); $html = ''; if($n==0) $html = false; return $html; } function buildBranch($parent_id, $level = 0) { global $customer_group_id, $group_categories_array; $result = $this->parent_group_start_string; if (isset($this->data[$parent_id])) { foreach ($this->data[$parent_id] as $category_id => $category) { $products = $this->get_products_in_category($category_id); $category_link = $category_id; $result .= $this->child_start_string; if (isset($this->data[$category_id])) $result .= $this->parent_start_string; if ($level == 0) $result .= $this->root_start_string; $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . ''; $result .= ''.$category['name'].''; $result .= ''; $result .= $products; if ($level == 0) $result .= $this->root_end_string; if (isset($this->data[$category_id])) $result .= $this->parent_end_string; $result .= $this->child_end_string; // estores excluded tabular category sub-categories and products 21092012 if($category['tabular']==0) { if (isset($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) { if($customer_group_id > 0) { if(is_array($group_categories_array) && in_array($category_id,$group_categories_array)) { $result .= $this->buildBranch($category_id, $level+1); } } else { $result .= $this->buildBranch($category_id, $level+1); } } } } } $result .= $this->parent_group_end_string; return $result; } function buildTree() { return $this->buildBranch($this->root_category_id); } } ?>