Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
This topic describes the indexing conventions for catalog content and how to make changes to the default behavior, in Commerce solutions where the Find search provider EPiServer.Find.Commerce is used.
To change default behavior, create a new class to override the conventions that are applied. The following example shows what class to inherit from, and how to register your implemenatation.
[ServiceConfiguration(ServiceType = typeof(CatalogContentClientConventions))]
public class MyCatalogContentClientConventions : CatalogContentClientConventions
{
}
Inventories get indexed for variations by default. The inventories are part of the variation document, and contain information about the inventory in different warehouses.
When the inventory event is trigged, the variation content is re-indexed. By removing the inventories from the variation, the content is not re-indexed on inventory updates.
protected override void ApplyIStockPlacementConventions(
TypeConventionBuilder<IStockPlacement> conventionBuilder)
{
base.ApplyIStockPlacementConventions(conventionBuilder);
conventionBuilder
.ExcludeField(x => x.Inventories());
}
Prices are indexed for variations by default, are part of the variation document, and contain information about prices for different users and groups.
When a price event is trigged, the variation content is re-indexed. By removing the prices, and default price from the variation, the content is not re-indexed on price updates.
protected override void ApplyPricingConventions(
TypeConventionBuilder<IPricing> conventionBuilder)
{
base.ApplyPricingConventions(conventionBuilder);
conventionBuilder
.ExcludeField(x => x.DefaultPrice())
.ExcludeField(x => x.Prices());
}
This method applies the default conventions. If you want to make a change, override this method, or any of the submethods, and add or remove conventions you need.
public override void ApplyConventions(IClientConventions clientConventions)
{
ApplyPriceConventions(clientConventions.ForInstancesOf<Price>());
ApplyPricingConventions(clientConventions.ForInstancesOf<IPricing>());
ApplyIStockPlacementConventions(clientConventions.ForInstancesOf<IStockPlacement>());
ApplyProductContentConventions(clientConventions.ForInstancesOf<ProductContent>());
ApplyAssociationConventions(clientConventions.ForInstancesOf<IAssociating>());
ApplyCustomerPricingConventions(clientConventions.ForInstancesOf<CustomerPricing>());
ApplyNodeRelationsConventions(clientConventions.ForInstancesOf<CatalogContentBase>());
ApplyEntryContentConventions(clientConventions.ForInstancesOf<EntryContentBase>());
ApplyBundleContentConventions(clientConventions.ForInstancesOf<BundleContent>());
ApplyPackageContentConventions(clientConventions.ForInstancesOf<PackageContent>());
ApplyCommerceMediaConventions(clientConventions.ForInstancesOf<CommerceMedia>());
ChangeConverterForInstancesOf<Money>(clientConventions, new Json.MoneyConverter());
ChangeConverterForInstancesOf<MarketId>(clientConventions, new Json.MarketIdConverter());
}
This method allows for IPricing to be indexed, meaning that the default price and all other prices are indexed with the associated content. Override this method if you want to change which fields are indexed.
protected override void ApplyPricingConventions(
TypeConventionBuilder<IPricing> conventionBuilder)
{
conventionBuilder
.IncludeField(x => x.DefaultPrice())
.IncludeField(x => x.Prices());
}
This method excludes the EntryContent field from the Price object when indexing. Leave this field excluded if you are indexing prices. If you are not indexing prices, remove this convention.
protected override void ApplyPriceConventions(
TypeConventionBuilder<Price> conventionBuilder)
{
conventionBuilder
.ExcludeField(x => x.EntryContent);
}
This method allows IStockPlacement to be indexed, meaning that inventory records are indexed with the associated content. Override this method if you want to change which fields are indexed.
protected override void ApplyIStockPlacementConventions(
TypeConventionBuilder<IStockPlacement> conventionBuilder)
{
conventionBuilder.IncludeField(x => x.Inventories());
}
This method allows for CustomerPricing objects to be properly indexed. If you are indexing prices, leave this convention as-is. If you are not indexing prices, remove this convention.
protected override void ApplyCustomerPricingConventions(
TypeConventionBuilder<CustomerPricing> conventionBuilder)
{
base.ApplyCustomerPricingConventions(conventionBuilder);
}
Last updated: Nov 03, 2015