我尝试制作简单的pdf发票:
class KM_PdfInvoice_Model_Sales_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice
已经为 PDF 设计了骨架布局。但现在我的问题是访问订单数据,例如:
订购的物品、客户姓名、送货、帐单地址等。当您按下按钮提交时:
或按下按钮打印:
getPdf() 正在执行:
public function getPdf($invoices = array()){
foreach ($invoices as $invoice) {
if ($invoice->getStoreId()) {
Mage::app()->getLocale()->emulate($invoice->getStoreId());
Mage::app()->setCurrentStore($invoice->getStoreId());
}
$OrderId = Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID);
$order = Mage::getModel('sales/order')->load($OrderId);
// echo $OrderId;
echo '<pre>';
print_r($order);
echo '</pre>';
但是$OrderId不想工作,所以我无法开始访问订单详细信息。我需要将订单 ID提供给 getPdf(); 我做错了什么?
PS我的config.xml:
<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<KM_PdfInvoice>
<version>1.0.0</version>
</KM_PdfInvoice>
</modules>
<global>
<models>
<sales>
<rewrite>
<order_pdf_invoice>KM_PdfInvoice_Model_Sales_Order_Pdf_Invoice</order_pdf_invoice>
</rewrite>
</sales>
</models>
</global>
</config>