Developer forum

Forum » Ecommerce - Standard features » Notes on products in FavoriteList

Notes on products in FavoriteList

Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi,

I need to add a note to the products in a customers FavoriteList.

If I look into the database, there is a field named "Note" in the table "EcomCustomerFavoriteProducts", but I cannot find the template-tags for getting and setting this note, in the documentation

Do I have to use the api, to get this one?

--
Best regards
Kurt Moskjaer Andersen 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Kurt

That field is not rendered or cannot be saved during add to favorite process. At some point long ago, the favorite list was changed to use the product list renderer and only renders product related information. You can however use the API to get the information. You can use CustomerProductListProduct.GetPagedProductsByListId to get the list of products in a favorite list and then locate the note information from that collection.

BR Nicolai

Votes for this answer: 1
 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi Nicolai,

Okay, is it possible for us to use the field to save a note for the products or is this depricated?

/Kurt 

 
Nicolai Pedersen
Reply

Yes, you can use the field!

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Found out myself. Thanks :)

/Kurt

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Well, I'm getting an error about "Violation of PRIMARY KEY" when saving the product to the list, using the following code:

CustomerProductListProduct customerProductListProduct = CustomerProductListProduct.GetProductByIdAndList(Convert.ToInt32(listNo), product.Id, product.LanguageId, product.VariantId);
customerProductListProduct.Note = note;
customerProductListProduct.Save();

The error says: Violation of PRIMARY KEY constraint 'DW_PK_EcomCustomerFavoriteProducts'. Cannot insert duplicate key in object 'dbo.EcomCustomerFavoriteProducts'. The duplicate key value is (12377, 600150, LANG1, ).

/Kurt

 
Nicolai Pedersen
Reply

Well, the exception tells it all... Do not add the same record twice - it seems this combination is in the database already.

BR Nicolai

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Well, yes it is, but I just need to update it with the note. That's why I call CustomerProductListProduct.GetProductByIdAndList()

/Kurt

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

It seems like your save-method cannot be used to update the product.
I guess I'll have to use plain SQL instead.

/Kurt

 
Nicolai Pedersen
Reply

Yes, just checked the code - it is not even used internally and the save method does not work...

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Okay, thanks :)

/Kurt

 

You must be logged in to post in the forum