Aspect Types
To implement a dynamic page, create an aspect type meta definition file that defines the attributes required for a particular business use. The aspect type meta definition file also defines the business object type that the merchant can bind to the page when the page is created. In the meta definition file for the page type, specify which aspect types are supported for the page type.
To view the schema file that describes the JSON formatting for the aspect type meta definition file, see Page Designer JSON Schemas.
Put the aspect type meta definition file in the following directory of the custom cartridge, or any arbitrary subdirectory within this directory:
<your_cartridge>/cartridge/experience/aspects
Valid values for supported_object_types
are 'category' or 'product'.
Using 'category' allows the merchant to assign pages to a category in the Page Designer UI and developers to retrieve them using PageMgr.getPageByCategory.
Using 'product' allows the merchant to assign pages to a product in the UI and developers to retrieve them using PageMgr.getPageByProduct..
You can also create an aspect type with no supported_object_type
declared. For example, you could implement a Product List page that depends on the
results of a query, not the assignment of a category, to determine which products to
display on the page.
The 'attribute_definitions' of the aspect type define which attributes should be passed in when rendering the page using PageMgr.renderPage.
The following examples show aspect meta definition files for a Product List page and a Product Detail page. The Product List page aspect type has one attribute for category and supports the object type category, which the merchant assigns during page creation. The Product Detail page aspect type has two attributes, one for product and one for category. The Product Detail page also supports the object type category, which the merchant assigns during page creation. All products in the assigned categories use the Product Detail page.
plp.json
{
"name": "Product List Page",
"description": "The product list page for a given category.",
"attribute_definitions": [
{
"id": "category",
"name": "Category",
"type": "category"
}
],
"supported_object_types": [
"category"
]
}
pdp.json
{
"name": "Product Details Page",
"description": "The product details page for a given product.",
"attribute_definitions": [
{
"id": "product",
"name": "Product",
"description": "The product to render the pdp for.",
"type": "product",
"required": true
},
{
"id": "breadcrumb_category",
"name": "Breadcrumb Category",
"description": "The optional category context of the pdp, for breadcrumb purposes.",
"type": "category",
"required": false
}
],
"supported_object_types": [
"category"
]
}
Specify the supported aspect types in the page definition file for the page type, as in
the following example. Because this page type declares support for the
plp
aspect type, the page requires the category attribute defined
in the plp.json
meta definition file. Category is the dynamic attribute
that the controller or script uses to render the page in the storefront.
plplayout.json
{
"name": "Product List Page Layout",
"description": "A layout for a product list page with a region to contain a product grid component.",
"supported_aspect_types": [
"plp"
],
"region_definitions": [{
"id": "main",
"name": "Main Region"
}]
}
You can create a page type that supports more than one aspect type. During page creation, the merchant selects which aspect type to use for the page by selecting a Page Purpose in the page creation wizard.
dynamiclayout.json
{
"name": "Dynamic Layout",
"description": "A generic layout whose region can use any kind of component.",
"supported_aspect_types": [
"plp",
"pdp"
],
"region_definitions": [{
"id": "main",
"name": "Main Region"
}]
}