public function checkSaleActivation(SaleActiveStatusCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
        $con->beginTransaction();

        try {
            $now = time();

            // Disable expired sales
            if (null !== $salesToDisable = SaleQuery::create()
                    ->filterByActive(true)
                    ->filterByEndDate($now, Criteria::LESS_THAN)
                    ->find()) {
                /** @var SaleModel $sale */
                foreach ($salesToDisable as $sale) {
                    $sale->setActive(false)->save();

                    // Update related products sale status
                    $dispatcher->dispatch(
                        TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
                        new ProductSaleStatusUpdateEvent($sale)
                    );
                }
            }

            // Enable sales that should be enabled.
            if (null !== $salesToEnable = SaleQuery::create()
                    ->filterByActive(false)
                    ->filterByStartDate($now, Criteria::LESS_EQUAL)
                    ->filterByEndDate($now, Criteria::GREATER_EQUAL)
                    ->find()) {
                /** @var SaleModel $sale */
                foreach ($salesToEnable as $sale) {
                    $sale->setActive(true)->save();

                    // Update related products sale status
                    $dispatcher->dispatch(
                        TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
                        new ProductSaleStatusUpdateEvent($sale)
                    );
                }
            }

            $con->commit();
        } catch (PropelException $e) {
            $con->rollback();
            throw $e;
        }
    }