Ermin Dedic
Ermin Dedic

Reputation: 21

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

Upvotes: 0

Views: 3118

Answers (3)

Rakowu
Rakowu

Reputation: 154

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)

Upvotes: -1

Huzaifa Mustafa
Huzaifa Mustafa

Reputation: 322

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();
    }

Upvotes: 1

mnaczenski
mnaczenski

Reputation: 1626

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

Upvotes: 1

Related Questions