function tep_get_parent_categories(&$categories, $categories_id) { $parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $categories_id . "'"); while ($parent_categories = tep_db_fetch_array($parent_categories_query)) { if ($parent_categories['parent_id'] == 0) { return true; } $categories[sizeof($categories)] = $parent_categories['parent_id']; if ($parent_categories['parent_id'] != $categories_id) { tep_get_parent_categories($categories, $parent_categories['parent_id']); } } }
function osC_CategoryTree($load_from_database = true) { global $languages_id; $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id 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 $c = array(); # Get the category path, $c is passed by reference 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[$categories['parent_id']][$id] = array('name' => $categories['categories_name'], 'count' => 0); } }
function tep_get_product_path($products_id) { $cPath = ''; $category_query = tep_db_query("select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id limit 1"); if (tep_db_num_rows($category_query)) { $category = tep_db_fetch_array($category_query); $categories = array(); tep_get_parent_categories($categories, $category['categories_id']); $categories = array_reverse($categories); $cPath = implode('_', $categories); if (tep_not_null($cPath)) { $cPath .= '_'; } $cPath .= $category['categories_id']; } return $cPath; }
private function get_category_path($category_id) { if (tep_not_null($category_id)) { $cPath_new = ''; $categories = array(); // Initialize the array so the function doesn't complain tep_get_parent_categories($categories, $category_id); $categories = array_reverse($categories); $cPath_new .= implode('_', $categories); if (tep_not_null($cPath_new)) { $cPath_new .= '_'; } $cPath_new .= $category_id; return 'cPath=' . $cPath_new; } return false; }
function tep_get_product_path($products_id) { $OSCOM_Db = Registry::get('Db'); $cPath = ''; $Qcategory = $OSCOM_Db->prepare('select p2c.categories_id from :table_products p, :table_products_to_categories p2c where p.products_id = :products_id and p.products_status = 1 and p.products_id = p2c.products_id limit 1'); $Qcategory->bindInt(':products_id', $products_id); $Qcategory->execute(); if ($Qcategory->fetch() !== false) { $categories = array(); tep_get_parent_categories($categories, $Qcategory->valueInt('categories_id')); $categories = array_reverse($categories); $cPath = implode('_', $categories); if (tep_not_null($cPath)) { $cPath .= '_'; } $cPath .= $Qcategory->valueInt('categories_id'); } return $cPath; }
function tep_get_product_path($products_id) { global $osC_Database; $cPath = ''; $Qcategory = $osC_Database->query('select p2c.categories_id from :table_products p, :table_products_to_categories p2c where p.products_id = :products_id and p.products_status = :products_status and p.products_id = p2c.products_id limit 1'); $Qcategory->bindTable(':table_products', TABLE_PRODUCTS); $Qcategory->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qcategory->bindInt(':products_id', $products_id); $Qcategory->bindInt(':products_status', 1); $Qcategory->execute(); if ($Qcategory->numberOfRows()) { $categories = array(); tep_get_parent_categories($categories, $Qcategory->valueInt('categories_id')); $categories = array_reverse($categories); $cPath = implode('_', $categories); if (tep_not_null($cPath)) { $cPath .= '_'; } $cPath .= $Qcategory->valueInt('categories_id'); } return $cPath; }