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 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试