Magento - 结帐成功行动给出错误

时间:2013-05-07 09:14:33

标签: php magento

我在自定义模块中覆盖了一个页面控制器,并在其中调用了我自己的模型:

我的成功行动是:

public function successAction()
    {
        if(Mage::getSingleton('customer/session')->isLoggedIn()) {
        $model = Mage::getModel('standingorders/standingorders');//my own model call
            $model->updateScheduleOrderId();//calling updateScheduleOrderId method
        }
        $session = $this->getOnepage()->getCheckout();
        if (!$session->getLastSuccessQuoteId()) {
            $this->_redirect('checkout/cart');
            return;
        }

        $lastQuoteId = $session->getLastQuoteId();
        $lastOrderId = $session->getLastOrderId();
        $lastRecurringProfiles = $session->getLastRecurringProfileIds();
        if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
            $this->_redirect('checkout/cart');
            return;
        }
        $session->clear();
        $this->loadLayout();
        $this->_initLayoutMessages('checkout/session');
        Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
        $this->renderLayout();
    }

我的模特功能: Standingorders.php

public function updateScheduleOrderId()
    {
    $write = Mage::getSingleton('core/resource')->getConnection('core_write');
    $read = Mage::getSingleton('core/resource')->getConnection('core_read');
     if(Mage::getSingleton('customer/session')->isLoggedIn()) {
     $customerData = Mage::getSingleton('customer/session')->getCustomer();
     $customer_id = $customerData->getId();
     }
        $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
        $cart_id = Mage::getSingleton('checkout/session')->getQuoteId();
        $queryselect = "SELECT product_id FROM standingorders WHERE customer_id=".$customer_id." AND cart_id=".$cart_id;        
        $productScheduled = $read->fetchAll($queryselect);    
        foreach($productScheduled as $item){
        $product_id = $item['product_id'];
        $query = "UPDATE standingorders SET standingorder_status=1,order_date=now() WHERE product_id=".$product_id." AND customer_id=".$customer_id." AND cart_id=".$cart_id;
      $write->query($query);
            }
        }

当我点击下订单按钮时​​,出现以下错误:

处理您的请求时出错 出于安全原因,默认情况下禁用异常打印。

错误日志记录号:511601193445

我的错误日志文件是:

a:5:{i:0;s:202:"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1";i:1;s:2045:"#0 /home/stallion/public_html/standingorder2/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/stallion/public_html/standingorder2/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/stallion/public_html/standingorder2/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/stallion/public_html/standingorder2/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT product_...', Array)
#4 /home/stallion/public_html/standingorder2/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('SELECT product_...', Array)
#5 /home/stallion/public_html/standingorder2/lib/Zend/Db/Adapter/Abstract.php(734): Varien_Db_Adapter_Pdo_Mysql->query('SELECT product_...', Array)
#6 /home/stallion/public_html/standingorder2/app/code/local/Stallioni/Standingorders/Model/Standingorders.php(29): Zend_Db_Adapter_Abstract->fetchAll('SELECT product_...')
#7 /home/stallion/public_html/standingorder2/app/code/local/Stallioni/Standingorders/controllers/OnepageController.php(215): Stallioni_Standingorders_Model_Standingorders->updateScheduleOrderId()
#8 /home/stallion/public_html/standingorder2/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Stallioni_Standingorders_OnepageController->successAction()
#9 /home/stallion/public_html/standingorder2/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('success')
#10 /home/stallion/public_html/standingorder2/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /home/stallion/public_html/standingorder2/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#12 /home/stallion/public_html/standingorder2/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#13 /home/stallion/public_html/standingorder2/index.php(80): Mage::run('', 'store')
#14 {main}";s:3:"url";s:51:"/standingorder2/index.php/checkout/onepage/success/";s:11:"script_name";s:25:"/standingorder2/index.php";s:4:"skin";s:7:"default";}

我用Google搜索但找不到解决方案。请帮助我!!

0 个答案:

没有答案