HCL Commerce Version 9.1.8.0 or later

Inventory and custom fields in a custom search profile

You can add custom fields in the search profile by editing your ZooKeeper configuration.

Before you begin

ZooKeeper stores named profiles in one of its nodes. You can create, update, delete the profiles, and get profiles using the profiles endpoint of the Query service. The endpoint for the profile is:
https://data_environment_hostname:30921/search/resources/api/v2/documents/profiles/profileName
No container needs to be restarted after you add a profile using this endpoint.
Ensure that you have mapped the field name in the ZooKeeper component node, as in the following example. To understand how search profiles are managed in ZooKeeper, see Configuring Query services in ZooKeeper. For more information about search profiles, see Search profiles.
{
    "valuemappingservice": {
        "valuemapping": [
            {
                "internalName": "CatalogEntryUserDataFieldNameMapping",
                "externalName": "CatalogEntryUserDataFieldNameMapping",
                "valuemap": [
                    {
                        "externalValue": "inventories.*.quantity",
                        "internalValue": "inventories.*.quantity"
                    },
     {
                        "externalValue": "workspace",
                        "internalValue": "workspaceName"
                    }
                ]
            }
        ]
    }
}
For inventory fields, search for parameters according to the pattern inventories.*.quantity. This search returns all numbered inventory items; for example, inventories.10501.quantity.

Procedure

  1. Use the following procedure to add term searches.
    1. i) Create custom profile.
      To find all inventory items found using the wildcard * search on the central term, in Custom Profile add the response field inventories.*.quantity.
      {
      	"parentProfileName": "HCL_findProductsBySearchTerm",
      	"profileName": "X_findProductsBySearchTerm",
      	"lookupProfileName": "X_findCatalogEntryById",
      	"query": {
      		"responseFields": [
      			"inventories.*.quantity",
      			“workspaceName”
      		]
      	}
      }
      
      If you want to find a specific inventory item, add response field in Custom Profile that specifies the inventory number. For example, inventories.10501.quantity.
       {
      		"parentProfileName": "HCL_findProductsBySearchTerm",
      		"profileName": "X_findProductsBySearchTerm",
      "lookupProfileName" : "X_findCatalogEntryById",
      		"query": {
      			"responseFields": [
      				"inventories.10501.quantity",
      				“workspaceName”
      			]
      		}
                  		}
      
    2. Create a lookup profile.
      {
      			"parentProfileName": "HCL_findCatalogEntryById",
      			"profileName": "X_findCatalogEntryById",
      			"query": {
      				"responseFields": [
      					"inventories.10501.quantity"
      				]
      			}
      }
      
      Note: If the hero product image feature is enabled, create the custom lookup profile with all the changes added inside X_findProductsBySearchTerm. HCL_findCatalogEntryById is the HCL internal profile use for lookup, this profile cannot be override as a custom profile. You can only create the extension profile from the HCL_findCatalogEntryById profile. If the hero product Image is disabled, the lookup profile is not in use.
  2. 2) For Category Browsing
    1. Create a custom profile.
      To find all inventory items according to their central term, add the response field inventories.*.quantity in Custom Profile.
      {
      		"parentProfileName": "HCL_findProductsByCategory",
      		"profileName": "X_findProductsByCategory",
      		"lookupProfileName": "X_findCatalogEntryByIdForBrowse",
      		"query": {
      			"responseFields": [
      				"inventories.*.quantity",
      				"workspaceName"
      			]
      		}
      }
      
      If you want to find a specific inventory item, add response field in Custom Profile that specifies the inventory number. For example, inventory.10501.quantity.
    2. Create a lookup profile.
      {
      			"parentProfileName": "HCL_findCatalogEntryByIdForBrowse",
      			"profileName": "X_findCatalogEntryByIdForBrowse",
      			"query": {
      				"responseFields": [
      					"inventories.*.quantity",
      					"workspaceName"
      				]
      			}
      }
      
      Note: If the hero product image feature is enabled, create the custom lookup profile with all the changes added inside X_findProductsByCategory. HCL_findCatalogEntryByIdForBrowse is the HCL internal profile used for lookup, this profile cannot be overriden as a custom profile. User can only create the extension profile from HCL_findCatalogEntryByIdForBrowse profile. If hero product image is disabled, the lookup profile is not in use.

Formatting fields with names that end in *

To format fields that end with * in the value mapping service in json, set formatUserData to the value true in the value mappings SearchConfiguration section. By default, the value is true for this flag.

Example

Following is a sample profile.
{
	"parentProfileName": "HCL_findProductsBySearchTerm",
	"profileName": "X_findProductsBySearchTerm",
	"lookupProfileName": "X_findCatalogEntryById",
	"query": {
		"responseFields": [
			"test.list",
			"test1.list1",
			"category.10001-10001.*"
		]
	}
}

{
	"parentProfileName": "HCL_findCatalogEntryById",
	"profileName": "X_findCatalogEntryById",
	"query": {
		"responseFields": [
			"test.list",
			"test1.list1",
			"category.10001-10001.*"
		]
	}
}
Sample mapping for custom fields:
	{
		"valuemappingservice": {
			"valuemapping": [
				{
					"internalName": "CatalogEntryUserDataFieldNameMapping",
					"externalName": "CatalogEntryUserDataFieldNameMapping",
					"valuemap": [
						{
							"externalValue": "List",
							"internalValue": "test.*"
						},
						{
							"externalValue": "List1",
							"internalValue": "test1.list1"
						},
						{
							"externalValue": "CategoryDetails",
							"internalValue": "category.*"
						}
					]
				}
			]
		}
}
After executing the term search API, the User Data section with custom fields is returned in the response.
"UserData": [
	{
		"List1": [
			"10",
			"20"
		],
		"CategoryDetails": [
			{
				"10001-10001": {
					"id": "10001",
					"name": "dresses",
					"sequence": "1.0"
				}
			}
		],
		"List": [
			{
				"list": "10"
			},
			{
				"list": "20"
			}
		]
	}
]

For List and List1 the response structure is different, because there are different mapping in the value mapping section. If the full field path is specified, a list similar to List1 will be returned. If the wildcard * is use in the field mapping, it will be formatted as a json object similar to the example List object.

Note: Do not override the following profiles. They are for HCL internal use only.
  • HCL_findCatalogEntryByIdForBrowse
  • HCL_findCatalogEntryById