Vaguely about the forewash created by the PDF process. Where is the code for processing logic?

I want to deeply understand prestahop inside the structure and change some parts. I have stopped at pdf. I can not find the controller used to handle AdminPdf and generateDeliverySlipPDF

    {if $order->delivery_number}
      <a class="btn btn-default _blank" href="{$link->getAdminLink('AdminPdf')|escape:'html':'UTF-8'}&amp;submitAction=generateDeliverySlipPDF&amp;id_order={$order->id}">
      <i class="icon-truck"></i>
    </a>
   {/if}

Who can help me figure out the internal processes? I can not find methods to handle generateDeliverySlipPDF.

+4
source share
1 answer

AdminPdfControllerlocated in /controllers/admin/AdminPdfController.php.

Part of the submitAction=generateDeliverySlipPDFURL will invoke the method processGenerateDeliverySlipPDF()inside this controller.

Here is the method:

public function processGenerateDeliverySlipPDF()
{
    if (Tools::isSubmit('id_order')) {
        $this->generateDeliverySlipPDFByIdOrder((int)Tools::getValue('id_order'));
    } elseif (Tools::isSubmit('id_order_invoice')) {
        $this->generateDeliverySlipPDFByIdOrderInvoice((int)Tools::getValue('id_order_invoice'));
    } elseif (Tools::isSubmit('id_delivery')) {
        $order = Order::getByDelivery((int)Tools::getValue('id_delivery'));
        $this->generateDeliverySlipPDFByIdOrder((int)$order->id);
    } else {
        die(Tools::displayError('The order ID -- or the invoice order ID -- is missing.'));
    }
}

, -, PDF .

, .


EDIT:

, :

/override/classes/pdf/PDFGenerator.php:

<?php

/**
 * @since 1.5
 */
class PDFGenerator extends PDFGeneratorCore
{

    /**
     * @param bool $use_cache
     * @param string $orientation
     * @param string $format
     */
    public function __construct($use_cache = false, $orientation = 'P', $format = 'A4')
    {
        TCPDF::__construct($orientation, 'mm', $format, true, 'UTF-8', $use_cache, false);
        $this->setRTL(Context::getContext()->language->is_rtl);
    }
}

/override/classes/pdf/PDF.php:

<?php

/**
 * @since 1.5
 */
class PDF extends PDFCore
{

    /**
     * @param $objects
     * @param $template
     * @param $smarty
     * @param string $orientation
     */
    public function __construct($objects, $template, $smarty, $orientation = 'P', $format = 'A4')
    {
        parent::__construct($objects, $template, $smarty, $orientation);
        $this->pdf_renderer = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE'), $orientation, $format);
    }
}

/override/controllers/admin/AdminPdfController.php:

<?php

class AdminPdfController extends AdminPdfControllerCore
{
    public function generatePDF($object, $template)
    {
        switch($template) {
            case PDF::TEMPLATE_DELIVERY_SLIP:
                $format = array(210, 50000); // Replace with your desired size
                break;
            default:
                $format = 'A4';
        }

        $pdf = new PDF($object, $template, Context::getContext()->smarty, 'P', $format);
        $pdf->render();
    }
}

PDF. $format

, . , - .

/cache/class_index.php , Prestashop.

+4

All Articles