'Email template variables in shopware 6
How can I dump variables available for my e-mail templates in shopware 6, and where can I find them if I cannot dump them. Thank you
Solution 1:[1]
There is no way to dump those variables in twig. You can have a look at the entity definitions, e.g. the order: https://github.com/shopware/platform/blob/c5b78af033b1438e497e28ec7b10ab25cedb8a0d/src/Core/Checkout/Order/OrderDefinition.php
And then you can check the linked entities and so on.
You could propably dump the variables in the send function of the mailservice: https://github.com/shopware/platform/blob/cb9229240c111c70594bbe7e1a8b4f018162dc44/src/Core/Content/MailTemplate/Service/MailService.php#L109
Solution 2:[2]
I know its late, but if someone else stumbles upon this, you can use MailBeforeValidateEvent
as follows:
public static function getSubscribedEvents()
{
return [
MailBeforeValidateEvent::class => 'mailValidate'
];
}
public function mailValidate(MailBeforeValidateEvent $event): void
{
// Here you get the template data
$templateData = $event->getTemplateData();
// Here you get the data
$data = $event->getData();
}
Solution 3:[3]
Use the MailService and dump it from there. All data will appear under Debug in your Symfony Console (in case you're using the development env from Git)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mnaczenski |
Solution 2 | Huzaifa Mustafa |
Solution 3 |