We bought and installed a gift card module from Magestore and when I was testing it on our staging website I noticed that it kept sending emails every two hours for the gift card.
How can I stop these emails? I have read that if I run this mysql command truncate table cron_schedule;
it will stop the emails from being sent, but won't that stop every email from being sent?
Also, any tips on how I can go about debugging this issue? I checked the modules code and they have some cron
jobs configured...
<crontab>
<jobs>
<giftvoucher>
<schedule>
<cron_expr>0 0 * * *</cron_expr>
</schedule>
<run>
<model>giftvoucher/observer::autoSendMail</model>
</run>
</giftvoucher>
<giftvoucherschedule>
<schedule>
<cron_expr>15 */2 * * *</cron_expr>
</schedule>
<run>
<model>giftvoucher/observer::sendScheduleEmail</model>
</run>
</giftvoucherschedule>
<giftvoucherautodeleteimage>
<schedule>
<cron_expr>30 0 * * *</cron_expr>
</schedule>
<run>
<model>giftvoucher/observer::autoDeleteImage</model>
</run>
</giftvoucherautodeleteimage>
<giftvoucherautodeleteimage1>
<schedule>
<cron_expr>45 0 1 * *</cron_expr>
</schedule>
<run>
<model>giftvoucher/observer::autoDeleteImage1</model>
</run>
</giftvoucherautodeleteimage1>
</jobs>
</crontab>
And when I check the Magestore_Giftvoucher_Model_Observer
class I see the below functions:
/**
* Send scheduled email
*/
public function autoSendMail()
{
if (Mage::helper('giftvoucher')->getEmailConfig('autosend')) {
$giftVouchers = Mage::getModel('giftvoucher/giftvoucher')->getCollection()
->addFieldToFilter('status', array('neq' => Magestore_Giftvoucher_Model_Status::STATUS_DELETED))
->addExpireAfterDaysFilter(Mage::helper('giftvoucher')->getEmailConfig('daybefore'));
foreach ($giftVouchers as $giftVoucher) {
$giftVoucher->sendEmail();
}
}
}
/**
* Send scheduled email for friend
*/
public function sendScheduleEmail()
{
$collection = Mage::getResourceModel('giftvoucher/giftvoucher_collection');
$timeSite = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
$collection->addFieldToFilter('is_sent', array('neq' => 1))
->addFieldToFilter('day_store', array('notnull' => true))
->addFieldToFilter('day_store', array('to' => $timeSite));
if (count($collection)) {
$translate = Mage::getSingleton('core/translate');
$translate->setTranslateInline(false);
foreach ($collection as $giftCard) {
$giftCard->save();
if ($giftCard->sendEmailToRecipient()) {
if ($giftCard->getNotifySuccess()) {
$giftCard->sendEmailSuccess();
}
}
}
$translate->setTranslateInline(true);
}
}
And in the giftvoucher
table their is a field called is_sent
, which has a value of 2
for the email address it keeps sending it to.
Do I just need to change the value on is_sent
in the database?