Search code examples
shopware

Shopware show product image in invoice pdf


I have issue with showing order product images in generated pdf invoices, but they are showed in credit notes. I have invoice template(index.tpl) where the images have to be showed. The credit note template (index_gs.tpl) which extends the invoice template(index.tpl) is working.

I need some help with the following:

  1. How to debug shopware requests and queries?
  2. Where is the data for templates loaded?

If you need information about anything like plugins, source of templates i will provide it.


Solution

  • Documents creation goes in Shopware_Components_Document.

    public static function getSubscribedEvents()
    {
        return [
            'Shopware_Components_Document::assignValues::after' => 'onAfterRenderDocument',
        ];
    }
    
    public function onAfterRenderDocument(\Enlight_Hook_HookArgs $args) {
        $document = $args->getSubject();
        $view = $document->_view;
        $Order = $view->getTemplateVars('Order');
        $User = $view->getTemplateVars('User');
        $userID = $Order['_order']['userID'];
        $orderID = $Order['_order']['id'];
        $shopID = $Order['_order']['subshopID'];
    
        $view->assign('customVar', 'Custom Value'); // This variable will be available in document.
    }
    

    How to debug shopware requests and queries?

    You can use var_dump/print_r + exit in method above to see what you need.