Skip to main content

Product Class

Zuora

Product Class

This article describes the Product class, its global methods, and the related classes. Use these classes and global methods to programmatically implement Bundling and Guided Selling.

The Product class is available in the Versions 7.0 and later of Zuora Quotes.

Product Class Properties

The Product class represents a product in the product catalog. The class includes the following properties.

Property Type Description
childrenProducts List <zqu.ChildProduct> List of Included, recommended, required and optional products under this product.
description String Description of this product.
name String Name of this product.
productFeatures List <zqu__ZFeature__c> Features included in this product.
productId Id Id of this product.
productOptionGroups List <zqu.ProductOptionGroup> List of product option groups included in this product.
productRatePlans List <zqu.ProductRatePlan> List of the rate plans included in this product.
productType Enum

Supported values are:

  • STANDALONE
  • BUNDLE
rootProductId Id Top level product Id in the bundle.
sfdcProduct Product2 The Salesforce Product object.

Product Class Global Methods

Use the following global methods to support Guided Selling in Zuora Quotes. 

Method Return Type Description
loadAllChildrenProducts List <zqu.Product>

Returns all children of the current Product.

loadAllProducts List <zqu.Product> Returns all products in the product catalog. This method does not respect bundle structure. This means all products belonging to a bundle will be returned as individual Product objects.
loadChildrenProducts List <zqu.ChildProduct> Returns the direct children of the current product.
loadProduct (Id productId) zqu.Product

Returns a single product identified by the input Id.

If the Id passed in belongs to a bundle product, only the top level Product is returned.

loadProductsWithChildren
(List < Id > productIds)
List <zqu.Product>

Returns a list of products identified by the input Id.

If any of the Ids passed in belong to a bundle product, the bundle product along with its child products (2 levels deep) are returned.

loadProducts
(List < Id > productIds)
List <zqu.Product>

Returns a list of products identified by the input Id. 

If any of the Ids passed in belong to a bundle product, only the top level product is returned.

ChildProduct Class

The ChildProduct class extends the zqu.Product class and has the following properties.

Property Type Description
optionType Enum (zqu.ChildProduct.ProductOptionType)

Supported values are:

  • INCLUDED
  • REQUIRED
  • RECOMMENDED
  • OPTIONAL 
productOption zqu__ProductOption__c The product option that links this product to the parent product in a bundle.
productOptionGroup zqu.ProductOptionGroup The product option group that this product belongs.

ProductRatePlan Class

The ProductRatePlan class has the following properties.

Property Type Description
effectiveEndDate Date

Effective end date of the rate plan.

The value is retrieved from the zqu__ProductRatePlan__c.zqu__EffectiveEndDate__c field.

effectiveStartDate Date

Effective start date of the rate plan.

The value is retrieved from the zqu__ProductRatePlan__c.zqu__EffectiveStartDate__c field.

productRatePlanOption zqu__ProductRatePlanOption__c Product rate plan option this product rate plan is linked to.
sfdcProductRatePlan zqu__ProductRatePlan__c The original product rate plan in the product catalog.

ProductOptionGroup Class

The ProductOptionGroup class has the following properties.

Property Type Description
childrenProducts List <zqu.ChildProduct> List of children products that this product option group links to the parent product.
maxOption Integer Maximum number of product options under the parent product. In the Guided Product Selector, your users will not be able to select more than this number of bundle components in the Guided Product Selector.
minOption Integer Minimum number of product options under the parent product. In the Guided Product Selector, your users will be required to select at least this number of bundle components.
name String Name of the product option group.
productOptionGroupId Id Id of the product option group.
sfdcProductOptionGroup zqu__ProductOptionGroup__c The original product option group defined in the product catalog.

Sample Code

This section presents example codes of the zqu.Product class global methods.

  • Load a single Product
zqu.Product singleProduct = zqu.Product.loadProduct('01tF0000004RJTn');
  • Load a list of Products
List < zqu.Product > multipleProducts = 
  zqu.Product.loadProducts(new List < Id >{'01tF0000004RJTn, 01tF0000004RJTo'});
  • Load all products in the Product Catalog. 
List < zqu.Product > allProducts = zqu.Product.loadAllProducts();
  • Load a list of Products in the following bundle structure:
    • Road Warrior Bundle
      • WIFI Connect
      • Music Lover Package
    • Music Stream 1
    • Music Stream 2
List < zqu.Product > productsWithChildren = 
  zqu.Product.loadProductsWithChildren(new List < Id >{'RoadWarriorBundleId'});

//WIFI Connect and Music Lover Package  
List < zqu.ChildProduct > childProducts = productsWithChildren[0].childrenProducts; 

for(zqu.ChildProduct cp : childProducts) {
  List < zqu.ChildProduct > musicLoverPackageChildren = 
     cp.childrenProducts; //Music Stream 1 and Music Stream 2
}
  • Load the direct children of the current Product
zqu.Product roadWarriorBundle = 
  zqu.Product.loadProduct(new List<Id> {'RoadWarriorBundleId'});

//Only loads WIFI Connect and Music Lover Package
List < zqu.ChildProduct > childProducts = roadWarriorBundle.loadChildrenProducts(); 
  • Load all children of the current Product
zqu.Product roadWarriorBundle = 
  zqu.Product.loadProduct((new List<Id{'RoadWarriorBundleId'});

//Loads WIFI Connect, Music Lover Package, Music Stream 1, and Music Stream 2
List < zqu.ChildProduct > childProducts = roadWarriorBundle.loadAllChildrenProducts(); 
  • Add a Product to a quote with a specific rate plan
List <zqu.Product> quoteProducts = new List <zqu.Product>();
zqu.Product zp = zqu.Product.loadProduct('some product2 id');
zqu.Quote newquote1 = new zqu.Quote.getInstance(quoteId);

// All rate plans are in this list : zp.productRatePlans
// Remove the rate plans that you do not want to add to the quote 
// from this list. The code below removes the first rate p
lan
// from the selected product.

zp.productRatePlans.remove(0);

quoteProducts.add(zp);

newquote1.addQuoteProducts(quoteProducts);