dqyl2374 2015-07-22 16:07
浏览 44

Cron PHP代码无法在Magento上运行并产生错误

So I inherited a product reviews module. A cron runs every 6 hours. It checks for when to send an email out, but has not been working as of late.

Here's the config.xml file part containing the crontab. The crontab node is only placed within .

<crontab>
    <jobs>
        <company_reviews_delay>
            <schedule>
                <cron_expr>* * * * *</cron_expr><!-- every 6 hours -->
            </schedule>
            <run>
                <model>reviews/adminhtml_observer::delaySend</model>
            </run>
        </company_reviews_delay>
    </jobs>
</crontab>

The php file with the delaySend method is in Reviews/Model/Adminhtml/Observer.php Here's the code for it

public function delaySend() {
    $error_counter = 0;

    $unsent_notifications = $this->getNotificationCollection()->addFieldToFilter('notified', array('lt' => 1));
    foreach($unsent_notifications as $notification){
        try{
            $order = Mage::getModel('sales/order')->loadByIncrementId($notification->getOrderId());

            if(!$this->getConfig()->isCronEnabled($order->getStoreId()) || !$this->getConfig()->isEnabled($order->getStoreId())){
                continue; //skip for store that is disabled
            }

            $shipments_collection = $order->getShipmentsCollection();

            if (empty($shipments_collection)) continue;
            $shipment = $shipments_collection->getFirstItem();
        }catch(Exception $e){
            if($error_counter == 0){
                mage::helper('mymodule_base')->logError('Review delay send error: ' . $e, true);
            }
            mage::helper('mymodule_base')->logError('Issue with notification order ID: ' . $notification->getOrderId(), false);
            $error_counter++;
            continue;
        }
        $execution_time =  strtotime($shipment->getCreatedAt().'+'. $this->getConfig()->getCronDelay($order->getStoreId())); //e.g (+1 day to shipping date)
        if($execution_time < time()){
            $notification->sendEmail($order->getStoreId());
        }
    }
    return $this;
}

I substituted a simple print "Hello"; command in the method and ran it on command line. Hello was printed out but we get this error:

2015-07-22T15:48:54+00:00 ERR (3): Warning: include(Symfony\Component\Console\Event\ConsoleTerminateEvent.php): failed to open stream: No such file or directory  in /home/os2/public_html/lib/Varien/Autoload.php on line 94
2015-07-22T15:48:54+00:00 ERR (3): Warning: include(Symfony\Component\Console\Event\ConsoleTerminateEvent.php): failed to open stream: No such file or directory  in /home/os2/public_html/lib/Varien/Autoload.php on line 94
2015-07-22T15:48:54+00:00 ERR (3): Warning: include(): Failed opening 'Symfony\Component\Console\Event\ConsoleTerminateEvent.php' for inclusion (include_path='/home/os2/public_html/app/code/local:/home/os2/public_html/app/code/community:/home/os2/public_html/app/code/core:/home/os2/public_html/lib:.:/usr/lib/php:/usr/local/lib/php')  in /home/os2/public_html/lib/Varien/Autoload.php on line 94

Can anyone offer some advice or help? Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧