fix issue where invalid SQL statement was called in cases where product categories had no contained products