简体   繁体   English

Magento 1.7:从订单确定创建发票,但是缺少交易

[英]Magento 1.7: Create invoice from an order OK, but the transaction is missing

I'm completely lost at this moment. 我现在完全迷路了。 I want to generate an invoice and a transaction for a given order. 我想为给定订单生成发票和交易。

here's the relevant part of the code: 这是代码的相关部分:

try {
  if(!$order->canInvoice()) {
    Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
  }

  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();

  if (!$invoice->getTotalQty()) {
    Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
  }
  $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
  $invoice->register();
  $transactionSave = Mage::getModel('core/resource_transaction')
        ->addObject($invoice)
        ->addObject($invoice->getOrder());

  $transactionSave->save();
} catch (Mage_Core_Exception $e) {
  print_r($e);
}

Everything works fine without errors and/or warnings, but the result is that I can clearly see the generated invoice in the Sales -> Orders -> #myorder -> Invoices tab, but the Transactions tab shows " No records found. ". 一切正常,没有错误和/或警告,但结果是我可以在“ Sales -> Orders -> #myorder -> Invoices选项卡中清楚地看到生成的发票,但是“ Transactions选项卡显示“未No records found. ”。

Is there something else I have to do? 我还有其他事要做吗?

Thanks. 谢谢。

Transaction data is stored in sales_payment_transaction 交易数据存储在sales_payment_transaction

sales_payment_transaction 
  website_magento.sales_payment_transaction has 24126 records
                       Field Type           Null Key Default  Extra Comment
            `transaction_id` int(10) unsign   NO PRI ┈   auto_increment  Transaction Id 
                 `parent_id` int(10) unsign  yes MUL ┈   ┈   Parent Id 
                  `order_id` int(10) unsign   NO MUL ┈   ┈   Order Id 
                `payment_id` int(10) unsign   NO MUL ┈   ┈   Payment Id 
                    `txn_id` varchar(100)    yes     ┈   ┈   Txn Id 
             `parent_txn_id` varchar(100)    yes     ┈   ┈   Parent Txn Id 
                  `txn_type` varchar(15)     yes     ┈   ┈   Txn Type 
                 `is_closed` smallint(5) un   NO     1  ┈   Is Closed 
    `additional_information` blob            yes     ┈   ┈   Additional Information 
                `created_at` timestamp       yes     ┈   ┈   Created At 

The output above is from development code I wrote to better understand Magento tables. 上面的输出来自我为更好地理解Magento表而编写的开发代码。 I have a form that takes a search string and replies with all field names and tables with that search string in their names. 我有一个采用搜索字符串并以其名称包含该搜索字符串的所有field namestables进行答复的形式。 I share my db helper functions with a Gist here ; 我在这里与Gist共享我的数据库帮助程序功能 I make a .php page just for me to run tests like this. 我为自己创建了一个.php页面来运行这样的测试。

Actual output of helper function below: 辅助函数的实际输出如下: 可视化我助手函数的输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM