Welcome to Zuora Product Documentation

Explore our rich library of product information

Sample code for Product Search Plugin

Sample Apex implementations of the Product Search Plugin that prioritize either rate plan or product name matches in Browse Products results.

Prioritize rate plan matches

The following example shows a basic plugin implementation that prioritizes rate plan name matches over product-name-only matches. Use this approach when users typically search by rate plan names and you want those matches to appear first in the Browse Products results.

global with sharing class MyProductSearchPlugin
implements zqu.ProductSearchPlugin.IProductSearchPlugin {

    global zqu.ProductSearchPlugin.SearchConfig getSearchConfig(
        zqu.ProductSearchPlugin.SearchContext context
    ) {
        zqu.ProductSearchPlugin.SearchConfig config =
            new zqu.ProductSearchPlugin.SearchConfig();
        config.sortBy = zqu.ProductSearchPlugin.SortPriority.RATE_PLAN;
        return config;
    }
}

If the user searches for pro in the following catalog:

  • Pro CRM / Standard

  • Pro CRM / Enterprise

  • Zuora Billing / Pro Annual

  • Zuora Billing / Pro Monthly

the results are ordered as follows:

  1. Zuora Billing / Pro Annual

  2. Zuora Billing / Pro Monthly

  3. Pro CRM / Enterprise

  4. Pro CRM / Standard

Prioritize product matches

This example shows a basic plugin implementation that prioritizes product name matches over rate-plan-only matches. Use this approach when users typically search by product names and you want those matches to appear first in the Browse Products results.

global with sharing class MyProductSearchPlugin
implements zqu.ProductSearchPlugin.IProductSearchPlugin {

    global zqu.ProductSearchPlugin.SearchConfig getSearchConfig(
        zqu.ProductSearchPlugin.SearchContext context
    ) {
        zqu.ProductSearchPlugin.SearchConfig config =
            new zqu.ProductSearchPlugin.SearchConfig();
        config.sortBy = zqu.ProductSearchPlugin.SortPriority.PRODUCT;
        return config;
    }
}

If the user searches for CPQ in the following catalog:

  • ABC / CPQ

  • CPQ / Microsoft

  • Zuora / CPQ

the results are ordered as follows:

  1. CPQ / Microsoft

  2. ABC / CPQ

  3. Zuora / CPQ