Magento PHP GiftCards Extension - 每分钟发送一次电子邮件GC

时间:2017-10-16 20:26:22

标签: php email magento e-commerce

我试图在Magento实施礼品卡延期。这是这个扩展名:https://www.webtexsoftware.com/gift-cards-magento-extension

我遇到的问题是我已经启用了电子邮件发送日期字段,但是当该日期到来时,它不会停止发送电子邮件。它每分钟发送一封电子邮件!

我确实有一个每分钟运行一次的cronjob来寻找必须发送的礼品证书,但据我所知,这不应该导致这个问题。

我已经尝试了所有我能想到的东西,以确保它不会在同一张礼品卡上运行两次,但不知何故。有任何想法吗?我希望每分钟运行一次,以确保我尽快将每个GC发送出去,但我不想要的是每分钟重新发送一次GC。

这是我的cronjob每分钟调用的PHP文件:

<?php
ini_set('memory_limit', '128M');
define('MAGENTO_ROOT', getcwd());

// exit;

$time = time();
$time2 = $time - 0;
$to = date('Y-m-d H:i:s', $time2);
$lastTime = $time - 120; //3600; // Orders from the past half hour
$from = date('Y-m-d H:i:s', $lastTime);
$mageFilename = ''; //removed for security
require_once $mageFilename;

Mage::app();
$order_collection = Mage::getResourceModel('sales/order_collection');

// $order_collection->addFieldToFilter('status', 'pending')

$order_collection->addAttributeToSelect('*')->addAttributeToFilter('updated_at', array(
    'from' => $from,
    'to' => $to
))

// ->addAttributeToFilter('updated_at', array('from' => $from, 'to' => $to))

->getSelect();
print count($order_collection);

foreach($order_collection->getItems() as $order) {
    $cards = Mage::getModel('giftcards/giftcards')->getCollection()->addFieldToFilter('order_id', $order->getId());
    print count($cards);
    foreach($cards as $card) {
        if (($card->getCardStatus() == 0) && ($curDate == $card->getMailDeliveryDate()))  {
                $card->setCardStatus(1)->save();
                if ((($card->getMailDeliveryDate() == null) || ($curDate == $card->getMailDeliveryDate())) && $card->getCardType() != 'offline') {
                    $card->send();
                }
            }
        }
    }
?>

0 个答案:

没有答案