Module: Commerce content modeling
37 of 38 Pages
Browse the commerce content modeling training guides
Now that we’ve gone over the content model for products, let’s start with a video tour of the implementation, followed by additional information on the key components in the text below.
Stock module
The finished branch of the Training guides repository includes a basic stock tracking example similar to the documentation’s example, with some minor name changes and code style adjustments.
The Training guides module makes the following key changes:
- A class override, which configures the stock class for Continuous Integration
- A field to hold the SKUCode value directly in the available stock class, to reduce extra querying in a hypothetical integration with warehouse inventory software
- Additional handlers for draft updates and deletion, to avoid orphaned stock when content items are deleted, and keep SKU codes up to date
- Evaluation based on the Product SKU Schema (
IProductSkuSchema) to determine whether to create a stock entry
See the code files behind the custom stock module in the repo:
For more complex stock tracking scenarios, consider expanding this module with one or more classes to represent different warehouses and stores, tracking stock separately for each. You can see examples of building a UI for multiple levels of related objects in the customization guides.
Catalog discount
The implementation includes a taxonomy-based catalog discount, as described in Catalog discount documentation, operating based on the ProductPriceSchemaDiscountCategory field of the Product price schema.
This allows editors to tag products for specific sale and discount events, such as Anniversary sale or Holiday special. Then, they can reference the same taxonomy tags from a catalog discount with its own start and end dates, meaning the discount will automatically stop affecting the product without the need to remove tags.
See the code files for catalog discounts in the repository:
Product widgets
The Training guides product catalog contains widgets that handle product display, both for listing and detail scenarios. We created both widgets using the KentiCopilot widget creation tools and refined them further with AI assistance using the documentation MCP server for context.
Listing widget with filtering
The Product listing widget displays an array of ProductPage wrappers that live under the page where it exists, or under a specified page, depending on editor configuration. It allows editors to specify how member-only pages are handled, and to configure CTA text for products and sign-in.
It includes taxonomy-based filtering that uses AND or OR logic between categories, depending on editor configuration. The filtering operates on taxonomies applied to product types via the Material schema and Color/Pattern schema, and in cases of parent/variant products, filters on the attributes of both.
See the listing widget’s code in the Training guides repo:
To learn more about the details of the filtering implementation, you can follow along with the product filtering example.
Detail widget
The Product widget displays the details of a product, allowing editors to choose between the page the widget exists on and a selectable ProductPage. It handles both basic products and parent products with variants. Editors can also configure whether variants are displayed, whether to include variant detail text, and an optional call-to-action link.
If the product has multiple images, customers can click through the gallery. If the product has variants and the widget is set to display them, they can click between variant thumbnails.
Find the code behind the Product widget in the repository:
Product service
The ProductService underlies much of the key functionality in both widgets, handling data retrieval, filtering, secured content, and view model assembly.
Explore the product service’s code in the repo:
Automatic page wrapper module
The product catalog implementation includes an event handler that automatically manages page wrappers for content hub products, saving editors from tedious busywork. It creates, publishes, unpublishes, and deletes ProductPage pages, manages their parent StoreSection pages, and automatically assigns page templates containing the aforementioned listing and detail widgets via API.
The handler reacts to both basic products and parent products, but not variants.
Walk through the process of creating this functionality in our product page wrapper material.
Look over the page wrapper handler code in the Training guides repository: