Blog filter and sort example

This product details example is used to introduce the features of the filter API. It's a simple product details schema with properties for SKU, title, category ID and product family, together with images and text. Several properties are configured to be filterable.

Pre-requisites

See the using the content type schema examples page for details of how to choose and register these schemas from the schema examples in Dynamic Content.

Note that this example uses the example-image and example-text schemas from the blog post example. You will need to register these schemas if you want to add image or text content.

How to use

Once you've registered the schema on this page, you should be able to follow the examples on the filter API page.

Product details schema

This is the main blog post content type schema. It includes a trait:filterable and trait:sortable as well as links to example-text and example-image. You can filter created from this schema by sku, categoryId, productFamily and whether it is hidden, as well as both productFamily and categoryId.

By default the content will be sorted in ascending order of priority.

{
   "$schema":"http://json-schema.org/draft-07/schema#",
   "$id":"https://schema-examples.com/pdp-content-block",
   "$comment":"Docs: https://amplience.com/docs/development/schema-examples/filter/filter-product-details.html",
   "title":"Product details",
   "description":"Product details that can be filtered and sorted",
   "allOf":[
      {
         "$ref":"http://bigcontent.io/cms/schema/v1/core#/definitions/content"
      }
   ],
   "type":"object",
   "properties":{
      "sku":{
         "title":"Product SKU",
         "description":"enter the exact product sku of the product where you want this to display",
         "type":"string",
         "minLength":0,
         "maxLength":20
      },
      "categoryId":{
         "title":"Category ID",
         "description":"Enter the ID of a product category",
         "type":"string",
         "minLength":0,
         "maxLength":100
      },
      "productFamily":{
         "title":"Product Family",
         "description":"Enter the name of a product category",
         "type":"string",
         "nullable":true,
         "minLength":0,
         "maxLength":100
      },
      "priority":{
         "title":"Priority",
         "description":"Rank the importance of this content",
         "type":"number",
         "minimum":0,
         "maximum":10
      },
      "hidden":{
         "title":"Hidden",
         "description":"Check to hide this content",
         "type":"boolean"
      },
      "content":{
         "title":"PDP Content",
         "description":"",
         "type":"array",
         "minItems":1,
         "maxItems":20,
         "items":{
            "allOf":[
               {
                  "$ref":"http://bigcontent.io/cms/schema/v1/core#/definitions/content-link"
               },
               {
                  "properties":{
                     "contentType":{
                        "title":"Content",
                        "enum":[
                           "https://schema-examples.com/example-image",
                           "https://schema-examples.com/example-text"
                        ]
                     }
                  }
               }
            ]
         }
      }
   },
   "propertyOrder":[

   ],
   "trait:filterable":{
      "filterBy":[
         {
            "paths":[
               "/sku"
            ]
         },
         {
            "paths":[
               "/categoryId"
            ]
         },
         {
            "paths":[
               "/productFamily"
            ]
         },
         {
            "paths":[
               "/hidden"
            ]
         },
         {
            "paths":[
               "/productFamily",
               "/categoryId"
            ]
         }
      ]
   },
   "trait:sortable":{
      "sortBy":[
         {
            "key":"default",
            "paths":[
               "/priority"
            ]
         }
      ]
   }
}

Content form preview

An example of creating a content item using a content type registered from the product details example schema is shown in the image below.

Content created from the product details example
Content created from the product details example

List, sort and filter content

Blog example

results matching ""

    No results matching ""