Custom automatic matching
If the default automatic matching strategy (OOTB automatic matching) is not aligned with your specific business requirements, select the custom match option. This option supports the use of ÃÛ¶¹ÊÓÆµ Developer App Builder to develop a custom matcher application that handles complex matching logic, or assets coming from a third-party system that cannot populate metadata into AEM Assets.
Configure custom automatic matching
-
From the Commerce Admin, navigate to Store > Configuration > ADOBE SERVICES > AEM Assets Integration.
-
Select Custom Matcher as the matching rule.
-
When you select this matching rule, Admin displays additional fields to configure the endpoints and the necessary authentication parameters for the custom matching logic.
Custom matcher API endpoints
When you build a custom matcher application using App Builder, the application must expose the following endpoints:
- App Builder asset to product URL endpoint
- App Builder product to asset URL endpoint
App Builder asset to product URL endpoint
This endpoint retrieves the list of SKUs associated with a given asset:
Example usage
const { Core } = require('@adobe/aio-sdk')
async function main(params) {
// Build your own matching logic here to return the products that map to the assetId
// var productMatches = [];
// params.assetId
// params.eventData.assetMetadata['commerce:isCommerce']
// params.eventData.assetMetadata['commerce:skus'][i]
// params.eventData.assetMetadata['commerce:roles']
// params.eventData.assetMetadata['commerce:positions'][i]
// ...
// End of your matching logic
return {
statusCode: 500,
body: {
asset_id: params.assetId,
product_matches: [
{
product_sku: "<YOUR-SKU-HERE>",
asset_roles: ["thumbnail", "image", "swatch_image", "small_image"],
asset_position: 1
}
]
}
};
}
exports.main = main;
Request
POST https://your-app-builder-url/api/v1/web/app-builder-external-rule/asset-to-product
assetId
eventData
assetId
Response
{
"asset_id": "{ASSET_ID}",
"product_matches": [
{
"product_sku": "{PRODUCT_SKU_1}",
"asset_roles": ["thumbnail","image"]
},
{
"product_sku": "{PRODUCT_SKU_2}",
"asset_roles": ["thumbnail"]
}
]
}
App Builder product to asset URL endpoint
This endpoint retrieves the list of assets associated with a given SKU:
Example usage
const { Core } = require('@adobe/aio-sdk')
async function main(params) {
// return asset matches for a product
// Build your own matching logic here to return the assets that map to the productSku
// var assetMatches = [];
// params.productSku
// ...
// End of your matching logic
return {
statusCode: 500,
body: {
product_sku: params.productSku,
asset_matches: [
{
asset_id: "<YOUR-ASSET-ID-HERE>", // urn:aaid:aem:1aa1d5i2-17h8-40a7-a228-e3ur588deee1
asset_roles: ["thumbnail", "image", "swatch_image", "small_image"],
asset_format: "image", // can be "image" or "video"
asset_position: 1
}
]
}
};
}
exports.main = main;
Request
GET https://your-app-builder-url/api/v1/web/app-builder-external-rule/product-to-asset
productSKU
asset_matches
productSku
.The asset_matches
parameter contains the following attributes:
asset_id
asset_roles
thumbnail
, image
, small_image
, and swatch_image
.asset_format
image
and video
.asset_position
Response
{
"product_sku": "{PRODUCT_SKU}",
"asset_matches": [
{
"asset_id": "{ASSET_ID_1}",
"asset_roles": ["thumbnail","image"]
},
{
"asset_id": "{ASSET_ID_2}",
"asset_roles": ["thumbnail"]
}
]
}