Developer forum

Forum » CMS - Standard features » Favorites Products in newsletter

Favorites Products in newsletter

Lars Pham
Reply

Yo!

I was wondering if this was possible using the Email Marketing module. 

 

I've created a User Smart Search that gets all users that have added a product to a Favorites List. 

So in Email Marketing: Can I create a newsletter that generates the favorited products for any users that matches the Smart Search criteria? 

 

So for example a logged in user adds 5 products to their favorite list and after a week they'll receive a newsletter containing these 5 products. 

Replies

 
Nicolai Pedersen
Nicolai Pedersen
Reply

I like where you are going, but Dynamicweb cannot do this out of the box as it is now. It requires a "context module" in order to do this.

You can in a Razor template that is being send from email marketing, get hold of PageView.Current.Context which holds information when emails are send "personalized" - using the "Render email for each recipient" setting on the email.

https://doc.dynamicweb.com/api/html/6d5a1c96-c0c8-6834-b14d-ffe9c691a9a4.htm

That object will hold a key with the user - call it like GetValue("UserID") - and cast it to an int and then query the favorite lists using SQL.

BR Nicolai

 
Lars Pham
Reply

Ah, very interesting :) 

Thank you! 

Is it possible to make SQL queries in smart searches?

I'd like to query users that added X products to a favorites list.
I don't think I can do that with the current rules in smart searches. 

 
Nicolai Pedersen
Nicolai Pedersen
Reply

Nope, but there are also ways to fix that.

If you create a custom field for a user "NumberofProductsOnFavoriteList" or whatever - then you can use the sql scheduled add-in run a SQL i.e. once a day, and let that SQL update all users with the number of products on their favorite list. Then the custom user field can be used very simple in the smartsearch.

And voila - you can query users with 5 or more products on their fav list.

BR Nicolai

 

You must be logged in to post in the forum