Prestashop:使用新的tpl重复发票PDF

时间:2017-02-13 11:08:37

标签: prestashop prestashop-1.6

如何在Prestashop中复制生成发票PDF流程?我想使用不同的tpl文件,但其余的应该保持不变。

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

  1. HTMLTemplateInvoice as HTMLTemplateMahnung并更改了Class Name。
  2. 补充:const TEMPLATE_MAHNUNG ='Mahnung';到文件类/ pdf / PDF.php
  3. 在root / pdf文件夹中创建文件mahnung.tpl
  4. 已添加到AdminPdfController.php:

    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.'));
    }}
    
  5. 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。

    任何帮助?

    更新

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

    现在它的工作。谁知道为什么我要这个?我没有看到任何包含Core Files:S

1 个答案:

答案 0 :(得分:0)

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

每次添加新覆盖,甚至是类或控制器时,都需要删除(或重命名)此文件。如果找不到它,Prestashop将重新创建索引集文件夹(类,控制器,覆盖等)中的所有文件。

相关问题