自訂自動比對

如果預設的自動比對策略(OOTB自動比對)不符合您的特定業務需求,請選取自訂比對選項。 此選項支援使用Adobe Developer App Builder來開發自訂符合器應用程式,以處理複雜的符合邏輯,或來自無法將中繼資料填入AEM Assets的協力廠商系統的資產。

設定自訂自動比對

  1. 從Commerce管理員中,導覽至「Store >設定> ADOBE SERVICES > AEM Assets Integration」。

  2. 選取​ Custom Matcher ​作為比對規則。

  3. 當您選取此比對規則時,Admin會顯示其他欄位,以設定​ 端點 ​和自訂比對邏輯所需的​ 驗證引數

自訂比對器API端點

當您使用App Builder建置自訂符合專案應用程式時,應用程式必須公開下列端點:

  • App Builder資產至產品URL ​端點
  • App Builder產品至資產URL ​端點

App Builder資產至產品URL端點

此端點會擷取與指定資產相關聯的SKU清單:

使用範例

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;

要求

POST https://your-app-builder-url/api/v1/web/app-builder-external-rule/asset-to-product
引數
資料型別
說明
assetId
字串
代表更新的資產ID。
eventData
字串
傳回與資產ID相關聯的資料裝載。

回應

{
  "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產品至資產URL端點

此端點會擷取與指定SKU相關聯的資產清單:

使用範例

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;

要求

POST https://your-app-builder-url/api/v1/web/app-builder-external-rule/product-to-asset
引數
資料型別
說明
productSKU
字串
代表更新的產品SKU。
eventData
字串
傳回與產品SKU相關聯的資料裝載。

回應

{
  "product_sku": "{PRODUCT_SKU}",
  "asset_matches": [
    {
      "asset_id": "{ASSET_ID_1}",
      "asset_roles": ["thumbnail","image"],
      "asset_position": 1,
      "asset_format": image
    },
    {
      "asset_id": "{ASSET_ID_2}",
      "asset_roles": ["thumbnail"]
      "asset_position": 2,
      "asset_format": image
    }
  ]
}
引數
資料型別
說明
productSKU
字串
代表更新的產品SKU。
asset_matches
字串
傳回與特定產品SKU相關聯的所有資產。

asset_matches引數包含下列屬性:

屬性
資料型別
說明
asset_id
字串
代表更新的資產ID。
asset_roles
字串
傳回所有可用的資產角色。 使用支援的Commerce資產角色,例如thumbnailimagesmall_imageswatch_image
asset_format
字串
提供資產的可用格式。 可能的值為imagevideo
asset_position
字串
顯示資產的位置。
recommendation-more-help
7c668478-e331-4212-aded-e9afab74d1bd