SELECT
COUNT(*)
FROM
cscart_promotions
LEFT JOIN cscart_promotion_descriptions ON cscart_promotion_descriptions.promotion_id = cscart_promotions.promotion_id
AND cscart_promotion_descriptions.lang_code = 'en'
LEFT JOIN cscart_storefronts_promotions AS storefronts_promotions ON storefronts_promotions.promotion_id = cscart_promotions.promotion_id
LEFT JOIN cscart_promotion_images ON cscart_promotion_images.promotion_id = cscart_promotions.promotion_id
AND cscart_promotion_images.lang_code = 'en'
WHERE
1
AND IF(
from_date, from_date <= 1730937939,
1
)
AND IF(to_date, to_date >= 1730937939, 1)
AND status IN ('A')
AND (
storefronts_promotions.storefront_id = 3
OR storefronts_promotions.storefront_id IS NULL
)
AND 1