Search for product variants
  • 09 Aug 2024
  • 2 Minutes to read
  • Dark
    Light

Search for product variants

  • Dark
    Light

Article summary

Due to the complexity of product manufacturing, numerous product variants are created over time. To streamline work with products, Zilliant CPQ allows you to view and reuse variants of a selected configurable product in three ways:

  • From the product configurator in a quote
  • Through Product Finder API
  • Through a Groovy script

From the product configurator in a quote

From the product configurator in quotes, Zilliant CPQ allows you to view and reuse variants of a configurable product that you want to add to a quote. To learn more about managing product variants from the product configurator, read Manage product variants.

Through Product Finder API

With Product Finder API, Zilliant CPQ users can search for variants of a specific product without the need to create a quote in the application. To learn more, read Product Finder API .

Through a Groovy script

By running a Groovy script, Zilliant CPQ users can search for variants of a specific product without the need to create a quote in the application.

To search for product variants through a Groovy script, follow these steps:

  1. Create a Groovy script.
  2. Upload the Groovy script to Zilliant CPQ.

Create a Groovy script

Create a Groovy script that lists all characteristics that variants of the specified product must have. This script supports the common binding variables and must call the following method:

MethodClassDescription
findProductFinderGroovyCtxUtil Searches for product variants that match provided characteristics.
Example Groovy script with comments
// Import necessary classes and libraries
import com.imc.vocabulary.Schema;
import com.imc.datamodel.BusinessObject
import java.util.List;
import com.imc.iss.web.resource.Resource
import java.util.Map;
import com.imc.iss.groovy.GroovyLogger
import com.google.common.collect.Maps;
import java.util.ArrayList;
import com.google.common.collect.Sets;

groovyLogger.notifyInfo("Welcome");
BusinessObject productBO = BusinessObject.create("<base_url>/Product#ID");


// List characteristics that product variants must match
List<Resource> resource =  new ArrayList<>(); 

Resource resource1 = new Resource()
resource1.put("type" , "DynamicDataAttribute")
resource1.put("uri", "<base_url>/DynamicDataAttribute#Body_Color")
resource1.put("value","Blue")
resource1.put("hasDataType", "<base_url>/application/schema.owl#StringType")
resource.add(resource1);


Resource resource2 = new Resource()
resource2.put("type" , "DynamicDataAttribute")
resource2.put("uri", "<base_url>/DynamicDataAttribute#Engine_Displacement")
resource2.put("value",1500)
resource2.put("hasDataType", "<base_url>/application/schema.owl#NumericType")
resource.add(resource2);

Resource resource3 = new Resource()
resource3.put("type" , "DynamicDataAttribute")
resource3.put("uri", "<base_url>/DynamicDataAttribute#IsElectricVarient")
resource3.put("value", true)
resource3.put("hasDataType", "<base_url>/application/schema.owl#BooleanType")
resource.add(resource3);

Resource[] resourceArray = new Resource[resource.size()];
resource.toArray(resourceArray);

groovyLogger.notifyInfo("Calling findProductFinder method with productBO: {}" + productBO.getUriAsString());  

// Call the findProductFinder method to get matching product variants
Collection<BusinessObject> products = groovyCtxUtil.findProductFinder(productBO, resourceArray); 


for(BusinessObject product : products)
{
    groovyLogger.notifyInfo("Product URI: " + product.getUriAsString());
}

return salesItemsTree;

Upload a Groovy script

Upload the Groovy script to Zilliant CPQ. At Step 5, select any of the existing Groovy exits to edit it. Then, in the Script File field, select your Groovy script file to upload.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.