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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
    • ¥30 数字电源对DSP芯片的具体要求
    • ¥20 antv g6 折线边如何变为钝角
    • ¥30 如何在Matlab或Python中 设置饼图的高度
    • ¥15 nginx中的CORS策略应该如何配置
    • ¥30 信号与系统实验:采样定理分析
    • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
    • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
    • ¥15 php 同步电商平台多个店铺增量订单和订单状态
    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别