此刻我完全迷失了。 我想为给定订单生成发票和交易。
这里是代码的相关部分:
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);
}
一切正常,没有错误和/或警告,但结果是我可以在Sales -> Orders -> #myorder -> Invoices
标签中清楚地看到生成的发票,但Transactions
标签显示" {{1 }}"
我还有别的事吗?
感谢。
答案 0 :(得分:0)
交易数据存储在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
上面的输出来自我编写的开发代码,以便更好地理解Magento表。我有一个表单,其中包含搜索字符串,并在其名称中使用该搜索字符串回复所有field names
和tables
。 I share my db helper functions with a Gist here;我只为我做了一个.php
页面来运行这样的测试。