Product Filter Callback

Product Filter Callback provides you a mechanism to control the visibility of products on the catalog page based on custom criteria that you define.

To use the Product Attribute Callback you must create a custom code that implements the IProductFilterCallback interface and register the custom code. You must write your custom logic in the C# custom code.

Feature Flag: is-productfiltercallback-enabled is the feature flag that enables the Product Filter callback.

The following methods are available in IProductFilterCallback interface:

Method

Signature

Description

GetProductFilterExpr()

GetProductFilterExpr(string cartId);

Callback to return Products Search Filter Expression & search the products which matches the criteria from catalog page.

(Parameter name cartId).

 

GetOptionFilterExpr()

GetOptionFilterExpr(string cartId)

Callback to return Option Search Filter Expression & search the products which matches the criteria from catalog page.

 

getExcludedOptionIds()

List getExcludedOptionIds(Apttus_Config2.CustomClass.ActionParams)

Callback to return option IDs which are to be excluded from the bundle.


Sample Code

using Conga.Revenue.Common.Callback.Models;
using Conga.Revenue.Common.Callback.Models.SearchFilter;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Conga.Revenue.Common.Callback
{
    /// <summary>
    /// This interface defines extension points for Product Filter Callback
    /// </summary>
    public interface IProductFilterCallback
    {
        /// <summary>
        /// Callback to return Product Search Filter Expression
        /// </summary>
        /// <param name="cartId"></param>
        /// <returns></returns>
        Task<ICriteria> GetProductFilterExpr(string cartId);

        /// <summary>
        /// Callback to return Option Search Filter Expression
        /// </summary>
        /// <param name="cartId"></param>
        /// <returns></returns>
        Task<ICriteria> GetOptionFilterExpr(string cartId);

        /// <summary>
        /// Callback to return option IDs which are to be excluded from the bundle
        /// This filter is used when we configure a bundle.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        Task<List<string>> GetExcludedOptionIds(IConfigModel config);
    }
}
CODE


Example

This is just a sample callback custom class to control the visibility of products on the Catalog page.

The following only filter the Catalog products having ExpirationDate greater than "2092-01-01", second method is used to exclude the list of productid mentioned within the list. You may change the custom class to fit your business requirements.

public class ProductFilterCallbackTest : CodeExtensibility, IProductFilterCallback

    {

        public async Task<ICriteria> GetProductFilterExpr(string cartId)

        {

            ICriteria criteria = new TestCriteria()

            {

                ObjectName = "Product",

                Filter = new TestFilter()

                {

                    Predicates = new List<IPredicate>()

                    {

                        new TestPredicate()

                        {

                            RowNum = 1,

                            FieldName = "ExpirationDate",

                            FieldLabel = "ExpirationDate",

                            FieldValue = "2092-01-01",

                            FieldType = "DATETIME",

                            CompOper = "greater than",

                            BoolOper = "AND"

                        }

                        

                    },

                    HasRHSFields = false,

                    CondExpr = "1"

                },

                Fields = new List<string>() { "Id" },

                ExprStr = "ExpirationDate > 2092-01-01"

            };

            return criteria;

        }

        public async Task<List<string>> GetExcludedProductIds(string cartId)

        {

            return new List<string>{

            "{productId01}",

"{productId02}"        }

//We are excluding {productId01} and {productId02}

    }
CODE

Option Filter Callback

Option filter callback in now clubbed with product filter callback.

Option Filter Callback provides you with a mechanism to control the visibility of the option products on the Configuration page based on the custom logic that you define. The callback is executed in the following scenarios:

  • when you click Configure on the Catalog page
  • when the configuration of the product is pending and you click the wrench icon ( ) on the Cart page. 

When callback is invoked, CPQ excludes the option products on the Configuration page.

Default options and options included based on constraint rules are also hidden when the Option Filter Callback is used to hide options. In the scenario, where all the case all the options in an option group are hidden, the option group is also hidden on the Configuration page.


Example

This is just a sample callback custom class to control the exclusion of option products on the catalog page. The following custom code only removes a few option products. You may change the custom class to list out the ID of option products to fit your business requirements.

global with sharing class SampleOptionFilterCallback implements Apttus_Config2.CustomClass.IOptionFilterCallback {
 
    /**
     * Callback to return option IDs which are to be excluded from the bundle
     * This filter is used when we configure a bundle.
     * @param params is the CustomClass.ActionParams that contains bundleId and productIds
     * @return List of option product IDs which will be excluded
     */
    global List<ID> getExcludedOptionIds(Apttus_Config2.CustomClass.ActionParams params) {
        //return new List<ID>{ <18 CHARACTER PRODUCT ID> };
        //Example for returning THREE products to be excluded:
            return new List<ID>{ '01t3C000000DVwh', '01t3C000000DVwm','01t3C000000DVww'};
        //Example for returning ONE product to be excluded:
        //  return new List<ID>{ 01t50000004nmL1YYX'};
    }    
}
CODE