Last active
October 27, 2023 16:45
-
-
Save caovillanueva/b267553a65a4f04e3172b7b760c730c5 to your computer and use it in GitHub Desktop.
[PS1.7] Query get all categories tree format. #ps17
This file contains 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
//$sql_tree = 'SELECT c.id_category,c.id_parent, CONCAT( LPAD( "", c.`level_depth` , "-" ) , cl.`name` ) AS NAME, cs.position ,level_depth ';//Display more info | |
$sql_tree = 'SELECT c.id_category as idcat '; | |
$sql_tree .= 'FROM ps_category c '; | |
$sql_tree .= 'LEFT JOIN ps_category_lang cl ON (c.id_category = cl.id_category AND id_lang = "1") '; | |
$sql_tree .= 'LEFT JOIN ps_category_group cg ON (cg.`id_category` = c.id_category) '; | |
$sql_tree .= 'LEFT JOIN `ps_category_shop` cs ON (c.`id_category` = cs.`id_category` ) '; | |
$sql_tree .= 'WHERE c.id_category > "2" '; | |
$sql_tree .= 'AND cl.id_lang="1" '; | |
$sql_tree .= 'AND c.active="1" '; | |
$sql_tree .= 'GROUP BY c.id_category '; | |
$sql_tree .= 'ORDER BY cs.position ASC,c.`id_parent` ASC,level_depth ASC'; | |
$qry_tree = mysqli_query($conn,$sql_tree);//get arrays | |
$category_tree = array(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment