Developer forum

Forum » Development » Change eCom custom-field on-the-fly

Change eCom custom-field on-the-fly


Reply
Hi,

How can I change a custom field value on a product-item on-the-fly with out change in the database.

It easy to change a "standard" field on-the-fly like:

Product.Meta.Keywords = "my keywords"

But how do I change a custom field value? What im looking for is something like this:

if ( you == "veryspecial") {
    Product.CustomFieldsXml["mycustomfield"] = "My Very Special Value";
}

... !?

/Morten

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
Hi Morten

The property you're looking for is called ProductFieldValues.

So what you do is:

prod.ProductFieldValues.GetProductFieldValue("yourcustomfield").Value = "Your Very Special Value";

NB.:
    prod is a Product ( duh ;-) )
    GetProductFieldValues can return null.
    "yourcustomfield" is the System Name of the field.

- Jeppe
 
Reply
Hi Jeppe,

Sweet ... Brilliant!
Just what I was lookin for :)

/Morten
 
Reply
Can I access custom-field on ecom groups in the same way - been trying - with no luck:

Dynamicweb.eCommerce.Products.Group myGroup = new Dynamicweb.eCommerce.Products.Group(HttpContext.Current.Request.QueryString["groupid"]);
Dynamicweb.Frontend.PageView.Current().Meta.Title = myGroup.ProductGroupFieldValues.GetProductGroupFieldValue("grouppagetitle").Value.ToString();

How is that done?

 

You must be logged in to post in the forum