Developer forum

Forum » Development » Accessing Customer favorite products

Accessing Customer favorite products

Dmitrij Jazel
Reply

Hi guys,

Wanted to ask if there is a easy way of accessing customers favorite products instead of accessing tables directly? :)

 

 


Replies

 
Morten Bengtson
Reply
This post has been marked as an answer

You can add a paragraph with the Customer Center module and create a template to display the loop of favorite products.

http://templates.dynamicweb-cms.com/eCommerce/Dynamicweb-eCommerce-template-tags/Customer-Center/Favorites-list/Loops/FavoriteList.aspx

 

 

You can get the favorite products programmatically by doing something like this...

 

int userId = Dynamicweb.Modules.UserManagement.User.GetCurrentUserID();
Collection<FavoriteList> lists = new Dynamicweb.eCommerce.CustomerCenter.FavoritesLists(userId);

foreach (FavoriteList list in lists)
{
	foreach (Product product in list)
	{
		// Do something?
	}
}

 

 

 

Votes for this answer: 1
 
Henrik Madsen
Reply

Hi Morten

I am new in Dynamicweb API... I have a problem creating a FavoriteList using the API. Can you show me how to creat a new list and add a product and the save is.

My test code look like this... but i can't save it?

 

Dynamicweb.Modules.UserManagement.User user;
user = Dynamicweb.Modules.UserManagement.User.GetUserByUserName("480010");
int userId = user.ID;
Collection<Dynamicweb.eCommerce.CustomerCenter.FavoritesList> lists = new Dynamicweb.eCommerce.CustomerCenter.FavoritesLists(userId);

Dynamicweb.eCommerce.CustomerCenter.FavoritesList item = new Dynamicweb.eCommerce.CustomerCenter.FavoritesList(1, "Favorit liste");
Dynamicweb.eCommerce.Products.Product p = Dynamicweb.eCommerce.Products.Product.GetProductByNumber("1600040");
item.Add(p);
lists.Add(item);
 

 

You must be logged in to post in the forum