"select `products`.* from `products` inner join `product_product_category` on `products`.`id` = `product_product_category`.`product_id` inner join `product_variants` on `products`.`id` = `product_variants`.`product_id` left join `product_sorts` on `product_sorts`.`product_id` = `products`.`id` and `product_sorts`.`category_id` = ? where `product_product_category`.`product_category_id` = ? and `products`.`active` = ? and `product_variants`.`active` = ? and `product_variants`.`deleted_at` is null and `product_variants`.`price` > ? and `products`.`orderable` = ? and `products`.`deleted_at` is null group by `products`.`id` order by ISNULL(product_sorts.sort), product_sorts.sort ASC, products.id DESC"