Created
June 21, 2016 10:35
-
-
Save veganista/c204b1e0b25379765b03a4595643ede9 to your computer and use it in GitHub Desktop.
Get the path to a category in opencart 1.5.*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns the path to a category in the format 1_2_3 | |
* @param int $category_id | |
* @return string the path to the category | |
*/ | |
public function getCategoryPath($category_id){ | |
$path = ''; | |
$category = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c WHERE c.category_id = " .(int)($category_id)); | |
if($category->row['parent_id'] != 0){ | |
$path .= $this->getCategoryPath($category->row['parent_id']) . '_'; | |
} | |
$path .= $category->row['category_id']; | |
return $path; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment