magento2-pdf-generator2
magento2-pdf-generator2 copied to clipboard
'Insert Variable' functionality in templares does not work (Exception, call on null)
In Magento 2.3.5 and Magento 2.4 as well, i can not make the variables to work.
When you try to create or edit a PDF template and press the 'insert variable' button an error occures:
Error: Call to a member function getId() on null in /app/web/vendor/magento/module-email/Block/Adminhtml/Template/Edit.php:295
...
I managed to find the potential cause for this, in Line 134-136 of /Controller/Adminhtml/Variable/Template.php bute evene if i changed it to something like this (as copied from module-email), its not fixed (but then you even will get json response...)
$templateBlock = $this->_view->getLayout()->createBlock(
\Magento\Email\Block\Adminhtml\Template\Edit::class,
'template_id',
[
'data' => [
'email_template' => $template
]
]
);
I assume that there have to be made several changes in order to make it compatible to the code of module-email. Actually there are many parts of the code which seem to be deprecated, so this might not be the only problem. Hard to say at this point... But might be a starting point for someone that had the same issue.
I can confirm that this is an issue on 2.3.5 and later
Hi, everybody, facing similar problem within 2.4.1 I am using layout definitions in the template like {{layout area="frontend" handle="jscdesign_shipment_date" shipment=$shipment order=$order}} But it generates as well the errors Call to member function on null
DId some body find a solution already? Regards, Chequille
Additional info: The above layout handle is calling a template but shipment and order data is not available there and therefore causes the error. In the template $shipment could be called with $shipment = $block->getShipment() Unfortunately not working anymore. It worked in 2.3.5 very good and stable.
the problem is here:
Pdfgenerator/Model/Template/Processor.php::processTemplate()
Setting setStrictMode to 0 fix this bug.
$processor->setStrictMode(0);
I am using Magento version 2.3.5-p1 and also having same error.
Fatal error: Uncaught Error: Call to a member function getId() on null
And cant get variables value on pdf, Please help to solve this issue.