Developer forum

Forum » Templates » Product AddToFavorites Question

Product AddToFavorites Question

Dmitrij Jazel
Reply

Hej guys,

In product catalog, when you are listing all products, you fo through loop, of products "var p" so you can generate "Add ToFavorites" url by calling this:

string addToFavorites = p.GetString("Ecom:Product.AddToFavorites")

 

Now, what if you are in Razor, and you get product instance by:

Dynamicweb.eCommerce.Products.Product prod = Product.GetProductByID(prodID);

// I want to do something like this

string addToFavorites = prod.GetString("Ecom:Product.AddToFavorites");

And than, you need to get the same string addToFavorites, can I somehow pull (.GetString("Ecom:Product.AddToFavorites")) out of product instance?

 

 


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

You can add the product to a favorite list like this

<form method="post">
 <input type='hidden' name='CCAddToMyLists' value="@product.ID"/>
 <input type='hidden' name='CCAddToListVariantID' value="@product.VariantID"/>
 <input type='hidden' name='CCAddToListLanguageID' value="@product.LanguageID"/>

 @* Use this as weel to add to a specific favorite list
 <input type='hidden' name='CCAddToListID' value='0'/>
 *@
 <button type="submit">@Translate("Add to favorites")</button>
</form>

Best regards,
Mikkel

Votes for this answer: 1
 
Dmitrij Jazel
Reply

Hej Mikkel,

Thanks for sharing great resource :)

I actually solved this one (in simmilar way as you posted here) but I got another issue now with adding product to favorites through API :)

Question posted in Developers section.

 

Still thanks allot for great code! :)

/Dmitrij

 

You must be logged in to post in the forum