Jump to content

Products from subcategories


Recommended Posts

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

×
×
  • Create New...