How to fill data from the Model to email context


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

Email variable:

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


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? 

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

$orderModel = Shopware()->Models()->getRepository(‘Shopware\Models\Order\Order’);

$orderModelEntity = $orderModel->findOneBy([‘id’ => 2]);


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


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

How can I sort it out?

Kind Regards,

Grzegorz Pietrzak

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…



Grzegorz Pietrzak