I have a crontab for giftcards that get sent when a delivery date is selected. It doesn't appear to be running.

This is in my config.xml:

                    <cron_expr>0 1 * * *</cron_expr>

This is the code in Observer that it's supposed to call:

     * Send email based on delivery date specified by customer
     * starts every day at 01.00 am (see config.xml)
    public function sendEmailByDeliveryDate()
        $currentDate = date('Y-m-d');
        $oGiftCards = Mage::getModel('giftcards/giftcards')->getCollection()
            ->addFieldToFilter('mail_delivery_date', array('eq' => $currentDate))
            ->addFieldToFilter('card_status', 1);
        foreach ($oGiftCards as $oGiftCard) {

1 Answer 1


First, I would check that your system cron is running. (Are other crons working, like emails being sent after an order is placed, for example?)

Second, I would write a shell script, like:

$model = Mage::getModel('giftcards/observer');

Save it to shell/testgiftcards.php. Then in your root folder, run "php shell/testgiftcards.php". If that works, then you can rule out your observer code as the problem. Check for any errors in system.log and exception.log.

If you are sure your cron is working, and that the observer code is executing successfully, add a log statement in your observer code:

public function sendEmailByDeliveryDate()
    Mage::log("Entered sendEmailByDeliveryDate()");

If you're not seeing that in system.log on a daily basis, then it might have something to do with your config xml, or your module might be set up incorrectly. Hopefully, doing the above will point you in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.