2017-02-13 28 views
1

如何在Prestashop中复制Generate Invoice PDF Process?我想使用不同的tpl文件,但其余的应该保持不变。Prestashop:使用新的tpl复制发票PDF

让我解释一下,我已经做了:

  1. HTMLTemplateInvoice为HTMLTemplateMahnung和改变类的名称。
  2. 加了:const TEMPLATE_MAHNUNG ='Mahnung';该文件中的类/ PDF/PDF.php
  3. 根/ PDF文件
  4. 加入AdminPdfController.php

  5. 创建文件mahnung.tpl:

    public function processGenerateMahnungPdf() { 
    if (Tools::isSubmit('id_order')) { 
        $this->generateMahnungPDFByIdOrder(Tools::getValue('id_order')); 
    } elseif (Tools::isSubmit('id_order_invoice')) { 
        $this->generateInvoicePDFByIdOrderInvoice(Tools::getValue('id_order_invoice')); 
    } else { 
        die(Tools::displayError('The order ID -- or the invoice order ID -- is missing.')); 
    }} 
    

public function generateMahnungPDFByIdOrder($id_order) 
{ 
    $order = new Order((int)$id_order); 
    if (!Validate::isLoadedObject($order)) { 
     die(Tools::displayError('The order cannot be found within your database.')); 
    } 

    $order_invoice_list = $order->getInvoicesCollection(); 
    Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); 
    $this->generatePDF($order_invoice_list, PDF::TEMPLATE_MAHNUNG); 
} 

但它不工作。它只是不会生成PDF。

任何帮助?

UPDATE

我必须包含类:require_once _PS_ROOT_DIR_。 '/classes/pdf/HTMLTemplateMahnung.php';

现在它的工作。任何人都知道我为什么要这样做?我没有看到任何包含的核心文件:S

回答

0

Pretashop使用文件缓存/ class_index.php来跟踪它需要的类。

每次添加新的覆盖,甚至是类或控制器时,都需要删除(或重命名)该文件。如果没有找到它,Prestashop会重新建立索引集文件夹(类,控制器,覆盖和其他)中的所有文件。

+0

非常感谢!这是问题... –