{"id":7744,"date":"2019-10-21T12:04:37","date_gmt":"2019-10-21T06:34:37","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=7744"},"modified":"2020-10-08T19:40:53","modified_gmt":"2020-10-08T14:10:53","slug":"get-sub-categories-from-parent-category-id-prestashop","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/prestashop\/get-sub-categories-from-parent-category-id-prestashop\/","title":{"rendered":"How to get sub-categories from parent category id in PrestaShop 1.7"},"content":{"rendered":"<p>In this post I am going to explain how to get sub-categories from parent category id in PrestaShop 1.7.<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">\/\/ Your Product id\r\n$id_parent_category = 3;\r\n\r\n\/\/ Fetch parent category\r\n$categoryObj = new Category($id_parent_category);\r\n\/\/ Validate category object\r\nif (Validate::isLoadedObject($categoryObj)) {\r\n\t$categoryList = $categoryObj-&gt;getSubCategories($this-&gt;context-&gt;language-&gt;id);\r\n\tif ($categoryList &amp;&amp; count($categoryList) &gt; 0) {\r\n\t\tforeach ($categoryList AS $key =&gt; $val) {\r\n\t\t\t\/\/ get sub category id\r\n\t\t\t$id_category = $val['id_category'];\r\n\r\n\t\t\t\/\/ get sub category name\r\n\t\t\t$name = $val['name'];\r\n\r\n\t\t\t\/\/ get sub category description\r\n\t\t\t$description = $val['description'];\r\n\t\t}\r\n\t}\r\n}<\/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=1779160656\" 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 sub-categories from parent category id in PrestaShop 1.7. &nbsp; \/\/ Your Product id $id_parent_category = 3; \/\/ Fetch parent category $categoryObj = new Category($id_parent_category); \/\/ Validate category object if (Validate::isLoadedObject($categoryObj)) { $categoryList = $categoryObj-&gt;getSubCategories($this-&gt;context-&gt;language-&gt;id); if ($categoryList &amp;&amp; count($categoryList) &gt; 0) { foreach ($categoryList AS&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/prestashop\/get-sub-categories-from-parent-category-id-prestashop\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":7838,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,222,2139,2],"tags":[629,313,331],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7744"}],"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=7744"}],"version-history":[{"count":1,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7744\/revisions"}],"predecessor-version":[{"id":7745,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7744\/revisions\/7745"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/7838"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=7744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=7744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=7744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}