{"id":7746,"date":"2019-10-21T12:02:09","date_gmt":"2019-10-21T06:32:09","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=7746"},"modified":"2020-10-08T19:41:32","modified_gmt":"2020-10-08T14:11:32","slug":"get-full-sub-categories-tree-from-root-category-id-prestashop","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/prestashop\/get-full-sub-categories-tree-from-root-category-id-prestashop\/","title":{"rendered":"How to get full sub-categories tree from root category id in PrestaShop 1.7"},"content":{"rendered":"<p>In this post I am going to explain how to get full sub-categories tree from root category id in PrestaShop 1.7.<\/p>\n<pre class=\"lang:default decode:true \">\/\/ Set your root category id\r\n$root_category_id = 2;\r\n\r\n\/\/ Set language id\r\n$language_id = $this-&gt;context-&gt;language-&gt;id;\r\n\r\n\/\/ Get category tree for given root category\r\n$category_tree = Category::getNestedCategories($root_category_id, $language_id);\r\n\r\n\/\/ Print category array and find the \"children\" element in each category\r\necho \"&lt;pre&gt;\";\r\nprint_r($category_tree);\r\necho \"&lt;\/pre&gt;\";<\/pre>\n<p>Thats it!<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1775836398\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this post I am going to explain how to get full sub-categories tree from root category id in PrestaShop 1.7. \/\/ Set your root category id $root_category_id = 2; \/\/ Set language id $language_id = $this-&gt;context-&gt;language-&gt;id; \/\/ Get category tree for given root category $category_tree = Category::getNestedCategories($root_category_id, $language_id); \/\/ Print category array and find&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/prestashop\/get-full-sub-categories-tree-from-root-category-id-prestashop\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":7833,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,222,2139,2],"tags":[629,313,329],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7746"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=7746"}],"version-history":[{"count":1,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7746\/revisions"}],"predecessor-version":[{"id":7747,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7746\/revisions\/7747"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/7833"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=7746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=7746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=7746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}