SELECT COUNT(cp.`id_product`) AS total FROM `ps_product` p INNER JOIN ps_product_shop product_shop ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 6) LEFT JOIN `ps_category_product` cp ON p.`id_product` = cp.`id_product` WHERE cp.`id_category` = 1241 AND product_shop.`visibility` IN ("both", "catalog") AND product_shop.`active` = 1