Define group_by_products_id as a method so its existence isn't dependent on the table existing

Fixes #1247