Source configuration approaches for availability channel

This is for:

Developer

Having your availability channel uploaded to a separate source offers benefits when creating your commerce catalog, but once you’ve set up your catalog configuration, you can only access information from product objects in the search response, as result folding can only be done on either a product with variants or its availability, but not both. An alternative solution to surface availability information is to leverage dictionary fields on the product object from the Catalog source. Let’s explore two scenarios:

Scenario 1: Two-source approach

On a standard search page, to filter products by availability, you use the two-source approach by having your products and variants contained in one source and your availabilities in another. Your product and variant source metadata will look like this:

// Product metadata
{
   "documentId": "product://001-red",
   "FileExtension": ".html",
   "ec_name": "Coveo Soccer Shoes - Red",
   "model": "Authentic",
   "ec_brand": ["Coveo"],
   "ec_description": "<p>The astonishing, the original, and always relevant Coveo style.</p>",
   "color": ["Red"],
   "ec_item_group_id": "001",
   "productid": "001-red",
   "ec_images": ["https://myimagegallery?productid"],
   "gender": "Men",
   "price_dict": {
        "": "28.00",
        "store1": "28.00",
        "store2": "30.00"
   },
   "ec_category": "Soccer Shoes",
   "objecttype": "Product"
 }

// Variant metadata

 {
   "documentId": "variant://001-red-8_wide",
   "FileExtension": ".html",
   "ec_name": "Coveo Soccer Shoes - Red / Size 8 - Wide",
   "sku": "001-red-8_wide",
   "productsize": "8",
   "width": "wide",
   "productid": "001-red",
   "objecttype": "Variant"
 }
//...

Your source for availability data will look like this:

{
    "documentId": "store://s000002",
    "ec_name": "Montreal Store",
    "lat": 45.4975,
    "long": -73.5687,
    "availableskus": ["001-red-8_wide","001-red-9_wide","001-red-10_wide","001-red-11_wide", "001-blue-8_wide"], 1
    "availabilityid": "s000002",
    "objecttype": "Availability"
 }
//...

Scenario 2: Single source approach

When you want to display availability information another way (for example, you need to surface availability information on the product template to control visibility of the “add to cart” button to establish whether a product is available in a specific location), your availability information needs to appear in the same Catalog source as part of your product or variant data. You would index your data under a single source and add the availability data info using the dictionary field.

Your product, variant and availability source data contained in a single source will look like this:

{
    "title": "This is a product title",
    "documentId": "product://000001",
    "clickUri": "https://www.coveo.com/000001",
    "ec_brand": "Coveo",
    "objecttype": "Product",
    "ec_shortdesc": "This is a short descripton",
    "sku": "000001",
    "modelnumber": "000001",
    "ec_item_group_id": "2x8AC2",
    "subsite": "Coveo",
    "wordcount": 11,
    "ec_price": 15.79,
    "ec_promo_price": 15.79,
    "availablestores": "0001;0002;0003;0004;0005;0006;0007",
    "shippingoptions": {
        "": "Ship to Home;Ship to Store",
        "0001": "Ship to Home;Ship to Store",
        "0002": "Ship to Home;Ship to Store",
        "0003": "Ship to Store",
        "0004" : "Ship to Home;Ship to Store",
        "0005" : "Ship to Home",
        "0006" : "Ship to Home",
        "0007" : "Ship to Store"
    }
}
//...

The availablestores field contains the list of stores, which will be used for filtering. The shippingoptions object (dictionary field) contains info specific to a store.