barrosa Posted March 8, 2013 Share Posted March 8, 2013 Hi! I am creating new module for work in category.tpl I need to extract the id of actual category and get products that are in subcategories of this parent category. Thank you Link to comment Share on other sites More sharing options...
NemoPS Posted March 9, 2013 Share Posted March 9, 2013 Hi There, If you only want those in the first child (or children) and not further subcategories, do this $id_category = (int)Tools::getValue('id_category'); //get subcategories IDS $sql = 'SELECT id_category FROM '._DB_PREFIX_.'category WHERE id_parent = '.$id_category.'; $subcategories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); Now create a string out of that result (if not empty!), and use another query to get products from category_product where id_category IN that list Hope this helps Fabio Link to comment Share on other sites More sharing options...
Recommended Posts