Magento自定义PDF发票模块

时间:2013-12-30 16:31:58

标签: magento pdf invoices

我尝试简单地制作pdf发票:

class KM_PdfInvoice_Model_Sales_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice

已经为PDF设计了骨架布局。但现在我的问题是访问ordes数据,如:

订购商品,客户名称,发货地址,帐单地址等。 当您按下提交按钮时: enter image description here

或按下按钮打印: enter image description here

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> 

1 个答案:

答案 0 :(得分:0)

要访问$ order,只需要调用:

            $order = $invoice->getOrder();