[IMP] product: filter and group by category_id on product.template

Was removed (for unknown reason) during refactoring of product and template (opw 611699)