# How to fill data from the Model to email context

**URL:** https://forum.shopware.com/t/how-to-fill-data-from-the-model-to-email-context/59972
**Category:** Programmierung
**Tags:** customelements
**Created:** [12. Juni 2019 um 12:23 UTC](https://forum.shopware.com/t/how-to-fill-data-from-the-model-to-email-context/59972 "2019-06-12T12:23:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Gregoraz](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@Gregoraz](https://forum.shopware.com/u/Gregoraz)
#### Post date: [12. Juni 2019 um 12:23 UTC](https://forum.shopware.com/t/how-to-fill-data-from-the-model-to-email-context/59972/1 "2019-06-12T12:23:30Z")

</div>

Hello,

I’m trying to fill the data(context)&nbsp;for email submission.

Email variable:

> $mail = Shopware() -\>TemplateMail() -\>createMail( ‚sORDERSTATEMAIL3‘, $context );

&nbsp;

Context variable:

> $context = array( ‚sUser‘ =\> [‚billing\_salutation‘ =\> ‚Mr‘, ‚billing\_lastname‘ =\> ‚Pietrzak‘], ‚sOrder‘ =\> [‚ordernumber‘ =\> $foundOne-\>getNumber(), ‚ordertime‘ =\> $foundOne-\>getOrderTime(), ‚status\_description‘ =\> $foundOne-\>getOrderStatus(), ‚invoice\_amount‘ =\> $foundOne-\>getInvoiceAmount(), ‚invoice\_amount\_net‘ =\> $foundOne-\>getInvoiceAmountNet(), ‚invoice\_shipping‘ =\> $foundOne-\>getInvoiceShipping()], );

My question is…

Do I have to set variables on that template like I’ve done above?&nbsp;

Can I set them somehow directly from selected model? Something like that:

> $orderModel = Shopware()-\>Models()-\>getRepository(‚Shopware\Models\Order\Order‘);
> 
> $orderModelEntity =&nbsp;$orderModel-\>findOneBy([‚id‘ =\> 2]);

&nbsp;

> $mail = Shopware() -\>TemplateMail() -\>createMail( ‚sORDERSTATEMAIL3‘, $orderModelEntity );

&nbsp;

I know that in createMail, the second argument is array, not the object…

How can I sort it out?

Kind Regards,

Grzegorz Pietrzak

---

<div class="post-metadata">

### Author: ![Gregoraz](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@Gregoraz](https://forum.shopware.com/u/Gregoraz)
#### Post date: [12. Juni 2019 um 14:35 UTC](https://forum.shopware.com/t/how-to-fill-data-from-the-model-to-email-context/59972/2 "2019-06-12T14:35:58Z")

</div>

Nevermind guys…

I can use Shopware()-\>Modules()-\>Order()-\>createStatusMail()

I was trying to write it by myself for whole day and I have no more comments to provide…

&nbsp;

Regards,

Grzegorz Pietrzak
