Getting the value of a custom field

To get the value of a custom field for a specific product, you must perform the following:

  1. Get the catalog manager.
    Get an instance of the CatalogManager object.
  2. Get the specified product.
    Get an instance of the product with the specified ID. For more information, see Querying products.
  3. Get the value of the field.
    To set the value of the field you must call the GetValue method of the product instance. Pass the name of the field as an argument.

Here is a code example:

public static object GetCustomFieldValue(Guid productId, string customFieldName)
{
    CatalogManager catalogManager = CatalogManager.GetManager();
 
    Product product = catalogManager.GetProduct(productId);
 
    if (product == null)
    {
        return null;     // Product does not exist
    }
 
    return product.GetValue(customFieldName);
}

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK