Customize exported product information
This topic describes how to customize which products are exported for use and which product data is included by Optimizely Product Recommendations in Optimizely Customized Commerce 13.
The export function has a few properties that can be set via code on the default CatalogFeedSettings instance:
var catalogFeedSettings = ServiceLocator.Current.GetInstance<CatalogFeedSettings>(); catalogFeedSettings.DescriptionPropertyName = "...";
|ExcludedAttributes||Product properties to exclude from the catalog feed.|
|DescriptionPropertyName||The product feed requires each item (product) to have a description. Set this value to the property name to use as description. Default value is "Description".|
|AssetGroupName||The first asset in this group is used for the item's image link. The default value is "default".|
API extension points
To use the following API extension points, add a custom implementation of an interface and register it in the dependency injection container. For more information, see the Dependency Injection articlein the Optimizely Content Management System (CMS) Developer Guide.
Implement this interface to exclude entries from the export. The default implementation excludes any entry that is not published.
This interface has methods that should return the quantity available for purchase. There are two methods:
- GetInventory(IEnumerable variations). This method's output is the quantity that should be considered available on the product level. The default implementation sums the quantity across all inventory locations and all product variants.
- GetInventory(EntryContentBase entry). This method's output is the quantity that should be considered available for an individual product variant, a product without its parent product, or a package. The default implementation sums the quantity across all inventory locations.
This interface has methods for getting the entry's URLs and an image representing the entry. These URLs are fed back in the recommendation data and are also used in other channels.
- GetExternalUrl(EntryContentBase entry). The URL of the entry's product detail page. The default implementation uses the normal content URL returned from IUrlResolver.
- GetImageUrl(EntryContentBase entry). The URL of the product image. The default implementation uses the URL of the first available asset (filtered by AssetGroupName in the Configuration, if set).
This interface lets you control which prices are used for an entry in the export. Each price consists of a default price and a sale price. You should return one price for each currency for which the entry has a price.
The default implementation gets all prices in all currencies for each market, using the AllCustomers price type, and selects the lowest unit price for each currency. For each price, the interface calls IPromotionEngine.GetDiscountPrices with the price's currency and market to get a sale price for the entry.
This interface contains three methods for getting product information:
GetTitle(EntryContentBase entryContent). Gets the product title. The default implementation uses the DisplayName if it is set, with a fallback to Name.
GetDescription(EntryContentBase entryContent). Gets the product description. The default implementation gets the value of the property named by DescriptionPropertyName in the Configuration.
GetAttributes(EntryContentBase entryContent). Gets additional product data to include in the export. The default implementation gets all non-system properties, filtered by ExcludedAttributes defined in the Configuration. A good way for a custom implementation to do more advanced filtering (or adding/changing values) is:
- Use the dependency injection intercept pattern (see Dependency Injection) to call the base implementation.
- Proceed with additional filtering.
Updated 2 months ago