我尝试简单地制作pdf发票:
class KM_PdfInvoice_Model_Sales_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice
已经为PDF设计了骨架布局。但现在我的问题是访问ordes数据,如:
订购商品,客户名称,发货地址,帐单地址等。 当您按下提交按钮时:
或按下按钮打印:
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(); 我做错了什么?
P.S我的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>
答案 0 :(得分:0)
要访问$ order,只需要调用:
$order = $invoice->getOrder();