Developer forum

Forum » CMS - Standard features » Live prices in newsletter

Live prices in newsletter

Alexander Tømmerholen
Reply

Hello,

Case:
Say I have three prices
- Normal price: 300 (in DW)
- Dealer price: 200 (in DW)
- Custom price: 100 (not in DW, live from Dynamics NAV)

In the newsletter I want to display the "custom price" for some specific users. I know the option "Render content for each recipient" has to be checked, and that works fine when I want to get the "dealer price". I`m also using the app "Product catalog for ViewModel" to make it work with "dealer price", but i`m not able to get the "custom price".

Is`it possible to get live prices from Dynamics NAV to be used in newletter?

 


Replies

 
Nicolai Pedersen
Reply

Hi Alexander

Yes, it is possible. Depending on the implementation of the live integration.

When sending out emails, Pageview.IsEmailContext is set to true. Then on the pageview there is a 'context' created by the email - userid is added to this context and can be retrieved like this:

Pageview.Context.GetValue("UserID")

In your priceprovider, you have something like this: public override PriceRaw FindPrice(PriceContext context, PriceProductSelection selection) - note that this is 9.12 version which has PriceContext. This price context has a Customer property of type user which is taken from the above email context if present.

So in your priceprovider, you have to ensure that the userid send to BC is using that property and NOT Security.UserManagement.User.GetCurrentExtranetUserId(); or similar.

In Live integration dll v2, that still uses the old findprice overload, Helpers.GetCurrentExtranetUser is doing the same thing.

So - how is your live integration getting your userid send to ERP?

You can use the user on the overload above - or this piece of code:

internal static User GetCurrentExtranetUser()
        {
            var user = User.GetCurrentExtranetUser();
            if (user == null && !string.IsNullOrEmpty(Context.Current?.Request?["UserId"]))
            {
                var userId = Core.Converter.ToInt32(Security.SystemTools.Crypto.Decrypt(Context.Current.Request["UserId"]));
                user = User.GetUserByID(userId);
            }
            return user;
        }

 

 

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> In Live integration dll v2, that still uses the old findprice overload, Helpers.GetCurrentExtranetUser is doing the same thing.

Is that correct? I see this in a recent version:

if (ProductManager.FetchProductInfos(products, User.GetCurrentExtranetUser()))

which uses User.GetCurrentExtranetUser(). Would that explain why live prices for newsletters don't work out of the box?

Or are you talking about the user instance passed to FindPrice?

Imar

 
Martin Moen
Reply

Hi Nicolai!

We do get the user id in the template using Pageview.Context.GetValue("UserID"), so everything is fine in the frontend.
But as Alexander is saying we still do not get the live price from NAV.

Just upgraded the solution to 9.12.4, so we should have the latest and greates live integration (see screenshot).
Still the live price from NAV does not want to be displayed :(

Everything is working just fine in the webshop, this is just a problem in the emails.

Screenshot_2021-12-01_191300.png
 
Nicolai Pedersen
Reply

@Imar - I can see that it was changed a couple of months ago - due to the same issue arising in Pim feeds - see below.

 

 

@Martin - what version of the live integration dll do you have?

Thanks, Nicolai

 
Martin Moen
Reply

@Nicolai:

Dynamicweb.Ecommerce.DynamicwebLiveIntegration.dll 6.1.0
Dynamicweb.Ecommerce.DynamicwebLiveIntegration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Build date Wed, 01 Dec 2021 18:43
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yep, thanks Nicolai. I was looking at the old source code base. Found the new version now.

Imar

 
Nicolai Pedersen
Reply

Hi Martin

Do you have this option set?

 
Martin Moen
Reply

Yes, "unfortunately" we do :)

 
Nicolai Pedersen
Reply

Alright. We will look into it further....

 

You must be logged in to post in the forum