NullReferenceException for OrderConfirmation

We have a problem when trying to send order confirmation email in Litium 7 Accelerator Mvc. We get a NullReferenceException in MailServiceImpl.cs on row 81

var page = pageMail.Page;
var pageUrl = _urlService.GetUrl(page, new PageUrlArgs(pageMail.ChannelSystemId) { AbsoluteUrl = true });

because this method in OrderConfirmationEmail.cs returns null

public override Page Page
{
    get
    {
        if (_page == null)
        {
            IoC.Resolve<PageByFieldTemplateCache<OrderConfirmationPageByFieldTemplateCache>>().TryFindPage(orderConfirmation =>
            {
                _page = orderConfirmation;
                return true;
            });
        }

        return _page;
    }
}

It seems page is not found in cache. Any ideas why? The order confirmation page is published and active on the channel.

Litium version: 7.1.0

Take a look at this link:

Ok, but I still don’t understand how to solve it, I can’t change channel id in code. I dont have a problem in

public override string GetOrderConfirmationPageUrl(OrderCarrier orderCarrier)
{
    var website = _websiteService.Get(orderCarrier.WebSiteID);
    var pointerPage = website.Fields.GetValue<PointerPageItem>(AcceleratorWebsiteFieldNameConstants.OrderConfirmationPage);

    return _urlService.GetUrl(_pageService.Get(pointerPage.EntitySystemId), new PageUrlArgs(pointerPage.ChannelSystemId));
}

my problems occurs in

IoC.Resolve<PageByFieldTemplateCache<OrderConfirmationPageByFieldTemplateCache>>().TryFindPage(orderConfirmation =>
            {
                _page = orderConfirmation;
                return true;
            });

But maybe it is related. Do I need to update database somehow?

No need for any changes in DB, check if visitors has right to see the page?

Yes.
Visitors has read access to order confirmation page.
Page is published and active on swedish channel.
We also get redirected to order confirmation page after purchase.

The class OrderConfirmationPageByFieldTemplateCache is part of accelerator so that can be modified with your needs, after a quick check my feeling is that the cache only is working for web-requests, not background execution like sending mail.

Please, report a bug.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.