Info

Method name: AttributeBasedCardinality

Use this step to enforce cardinality check based on attribute configuration. You can configure following rules:

  • a product with certain combination of attribute values requires between min and max amount of related product with certain combination of its own attribute values.
  • different attributes and different values can be selected for both products.
  • related product can be requested to appear as sibling or as a direct child.
  • product quantities are respected.
  • if there will be a number of products which match the rule, related products quantity will be evaluated for each of them.

Populate Pricing Context Params

For performance reasons, regardless of how many attributes are used in the rule, attribute JSON will be parsed once for each cart item. This applies also to subsequent pricing plan steps referring to attibutes of the same cart items, ie. attribute JSON for each cart item will be parsed once for whole pricing plan.

Params

This step takes no parameters. All rules are configured in custom settings:

Custom setting AttributeBasedProductCardinality__c fields:

  • ProductCode__c: code of product
  • AttributeCodesList__c: semicolon separated list of attribute codes
  • AttributeValuesList__c: semicolon separated list of attribute values
  • RelatedProductHierarchyPath__c: in case of sibling product code of related product, in case of child product hierarchy path
  • RelatedProductName__c: related product name
  • RelatedAttributeCodesList__c: related product semicolon separated list of attribute codes
  • RelatedAttributeValuesList__c: related product semicolon separated list of attribute values
  • Min: minimum number of related products per 1 product
  • Max: maximum number of related products per 1 product
  • ErrorMessage__c: error message template

Error message template uses curly-bracket {1} notation to include dynamic parameters from rule definition:

  • {0} minimum number of related products
  • {1} maximum number of related products
  • {2} actual number of related products
  • {3} name of the product
  • {4} name of related product
  • {5} atrtibute values of the product
  • {6} atrtibute values of related product

Configuration example

  • ProductCode__c: ‘PRD-018’
  • AttributeCodesList__c: ‘ATTR-Size’
  • AttributeValuesList__c: ‘38mm’
  • RelatedProductHierarchyPath__c: child - ‘PRD-018<PRD-087’, sibling - ‘PRD-087’
  • RelatedProductName__c: ‘Cloud Consultancy Services’
  • RelatedAttributeCodesList__c: ‘ATTR-Vendor’
  • RelatedAttributeValuesList__c: ‘Salesforce’
  • Min: 1
  • Max: 2
  • ErrorMessage__c: ‘{3}{5} requires {0}-{1} of {4}{6} but found {2}!’