^ """
SELECT p.id_product FROM (SELECT p.id_product, p.id_manufacturer, SUM(sa.quantity) as quantity, p.condition, p.weight, p.price, psales.quantity as sales, p.on_sale, p.date_add, cp.position, (SUM(sa.quantity) > 0) AS availability_store FROM ps_product p LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product) LEFT JOIN ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute) LEFT JOIN ps_stock_available sa ON (p.id_product = sa.id_product AND IFNULL(pac.id_product_attribute, 0) = sa.id_product_attribute AND sa.id_shop_group = 1 AND sa.id_shop = 0 ) LEFT JOIN ps_product_sale psales ON (psales.id_product = p.id_product) INNER JOIN ps_category_product cp ON (p.id_product = cp.id_product) INNER JOIN ps_product_shop ps ON (p.id_product = ps.id_product AND ps.id_shop = 1 AND ps.active = TRUE) INNER JOIN ps_category c ON (cp.id_category = c.id_category AND c.active=1) LEFT JOIN ps_category_group cg ON (cg.id_category = c.id_category) LEFT JOIN ps_specific_price sp_1 ON (\n
sp_1.id_product = p.id_product AND \n
sp_1.id_shop IN (0, 1) AND \n
sp_1.id_currency IN (0, 1) AND \n
sp_1.id_country IN (0, 86) AND \n
sp_1.id_group IN (0, 1) AND \n
sp_1.from_quantity = 1 AND\n
sp_1.reduction > 0 AND\n
sp_1.id_customer = 0 AND\n
sp_1.id_cart = 0 AND \n
(sp_1.from = '0000-00-00 00:00:00' OR '2025-07-27 11:39:04' >= sp_1.from) AND \n
(sp_1.to = '0000-00-00 00:00:00' OR '2025-07-27 11:39:04' <= sp_1.to) \n
) LEFT JOIN ps_feature_product fp_2 ON (p.id_product = fp_2.id_product) WHERE ((sa.quantity>0)) AND ((sp_1.reduction>0)) AND ((fp_2.id_feature_value=89)) AND ps.id_shop='1' AND ps.visibility IN ('both', 'catalog') AND cg.id_group='1' AND c.nleft>=17 AND c.nright<=18 GROUP BY p.id_product) p INNER JOIN ps_category_product cp ON (p.id_product = cp.id_product) GROUP BY p.id_product ORDER BY p.position ASC
"""
123