Query custom fields for product types

Query a single custom field

To query a single custom field, you must perform the following:

  1. Get an instance of the ecommerce manager.
    Get an instance of the EcommerceManager object. 
  2. Get the specified product type.
    Get an instance of the product type that the field belongs to. For more information, see For developers: Query product types.
  3. Resolve the product CLR type.
    To resolve the product CLR type, call the static ResolveType method of the TypeResolutionService. As an argument use the value of the ClrType property of the ProductType instance.

    NOTE: To use the ResolveType method to resolve the dynamic product type, you must make sure that you have instantiated the CatalogManager before that. In this example the CatalogManager is instantiated in order to get the product type.

  4. Get an instance of the metadata manager.
    Get an instance of the MetadataManager object.
  5. Get the meta type for the specified product type.
    To get the meta type, call the GetMetaType method of the metadata manager and pass the resolved product CLR type as an argument.
  6. Get the specified field.
    Filter the Fields collection of the MetaType instance by the name of the field.

Use the following code sample:

Query custom fields by a product type

To query a single custom field, you must perform the following:

  1. Get an instance of the ecommerce manager.
    Get an instance of the EcommerceManager object.
  2. Get the specified product type.
    Get an instance of the product type that the field belongs to. For more information, see For developers: Query product types.
  3. Resolve the product CLR type.
    To resolve the product CLR type, call the static ResolveType method of the TypeResolutionService. As an argument use the value of the ClrType property of the ProductType instance.

    NOTE: To use the ResolveType method to resolve the dynamic product type, you must make sure that you have instantiated the CatalogManager before that. In this example the CatalogManager is instantiated in order to get the product type.

  4. Get an instance of the metadata manager.
    Get an instance of the MetadataManager object.
  5. Get the meta type for the specified product type.
    To get the meta type, call the GetMetaType method of the metadata manager and pass the resolved product CLR type as an argument.
  6. Get the fields.
    The fields are stored in the Fields collection of the MetaType instance.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?