Product Administration Guide > Configuration Rule Template Reference >
Provide and Consume Templates
The Provide template has the form:
[An item] provides [a value] to [a target]
The Consume template has the form:
[An item] consumes [a value] from [a target]
Provide and consume rules positively or negatively increment the amount of the target operand each time the specified item is added to the solution. Provide rules contribute a positive amount, that is they increase the amount of the target. Consume rules contribute a negative amount, that is they reduce the amount of the target.
Contrast this with the behavior of require rules. For example, Item A requires Item B. The first time the user picks Item A, if no item B is in the solution, the eConfigurator engine will add at least one Item B. The second time the user picks Item A, the engine does not increment Item B because the require rule does not consider the quantity of Item A in the solution, only that Item A is present.
Now consider the rule Item A provides 1 to Item B. Each time the user picks Item A, the eConfigurator engine increments the number of Item B in the solution by 1. This rule ties the quantities of Item A and Item B together so that each Item A requires an Item B. Provide and consume rules work directly with quantities expressed as resource or attribute values, while require rules consider only the presence or absence of an item.
The Item operand can be a product, a relationship, a product class within a relationship, a resource or an attribute. If the item is a relationship or class, the rule applies to all the items in the relationship or class. For example, Relationship A provides 1 to Item B. Each time an item from Relationship A is added to the solution, Item B is added to the solution.
The value operand defines the quantity to be contributed to the target. The Rule Designer provides several methods for determining this quantity:
- You can explicitly state the quantity, for example Item A consumes 1 from Item B. This rule means that each Item A added to the solution decreases the amount of Item B in the solution by 1.
- You can define the value as the quantity of another item, or the value of an attribute, linked item or resource. For example, Item A provides three times the quantity of Item B to Item C. This rule means that for each Item A added to the solution, the quantity of Item C is incremented by three times the quantity of Item B.
- You can define an expression that determines which products in the relationship or class specified in Item will increment the target. For example: Any item of Relationship A provides Relationship A, Attribute Color = Red to Item B. This rule means that for each item in Relationship A for which the attribute Color = Red that is added to the solution, the quantity of Item B is incremented by one.
The target operand is incremented by the amount specified in the value operand. The target can be a product, resource, or product attribute. It cannot be a relationship, a class, or an expression.
When the target operand is a product, the quantity of the product is incremented. For example, Product A provides 2 to Product B. This rule means that each Product A added to the solution increases the quantity of Product B (the target) by 2.
The consume rule works the same way. For example, Product A consumes 2 from Product B. This rule means that each Product A added to the solution decreases the quantity of Product B (the target) by 2.
When the target is a resource, the value of the resource is incremented. One of the most common uses of provides and consume rules is to manage resources.
Resources keep track of configuration variables that increase or decrease as the user makes selections. For example, suppose you are creating a customizable product for configuring desktop computers. Your product includes several types of chassis. Each chassis has a different number of slots for expansion cards. The product also includes several types of expansion cards, such as disk controllers, and graphics cards.
You do not know in advance which chassis the customer will select or how many expansion cards. However, you do know you must keep track of the number of slots available in a chassis during the configuration process to verify that the computer is configured correctly.
Using provide and consume rules to increment a resource is the way to handle this:
- First define a resource to keep track of slots, for example Slots Available.
- Then define an attribute called Slots on the chassis class. Create a list of values of data type integer. Create one record for each chassis type. The value for each record is an integer equal to the number of slots in the chassis type. This creates a menu of choices for setting the number of slots in a chassis. Assign the list of values to the Slots attribute definition.
- Display the attributes for each chassis and set the value of the Slots attribute and save the record. This sets the number of slots in the chassis and prevents it from being changed by the user or the eConfigurator engine.
- Add the chassis class to a relationship, Chassis.
- Define an attribute called Slots Required on the expansion card class. Use a range of values domain and set the data type to Integer. Enter: ==1 as the validation expression. Enter 1 as the default value.
- Display the attributes for each expansion card and save the Slots Required record. This sets the number of slots required at 1 and prevents it from being changed by the user or the eConfigurator engine.
- Add the expansion card class to a relationship, Expansion Card.
- Write the following rule: Chassis provides Chassis Slots to Slots Available.
- Write the following rule: Expansion Card consumes Expansion Card Attribute = Slots Required from Slots Available.
- Write rules as needed to determine what happens if Slots Available is 0 or if it becomes negative.
When the user selects a chassis, the provide rule increases the Slots Available resource by the number of slots in the chassis. Each time the user selects an expansion card, the consume rule decreases the Slots Available resource by one. Thus, the Slots Available resource maintains a record of how many slots are available in the chassis during the configuration session.
If a resource has the same name in two different customizable products, the eConfigurator engines treats them as the same resource. You can take advantage of this in cases where one customizable product is contained within another. For example, customizable product CP2 is contained within customizable product CP1. You define resource R1 in both products. Rules in either customizable product that contribute to R1, affect the value of R1 in both products. Use this behavior to allow a parent customizable product to contribute to a resource in a child customizable product.
When the target is an attribute, the value of the attribute is incremented. Attribute targets are very similar in behavior and use as resource targets. There are several restrictions on using provide and consume rules to manipulate attribute values:
- The data type of the attribute must be numeric (Integer or Number).
- The attribute must be available for manipulation. You must not have set the value of the attribute. You do this by selecting an attribute value and saving it in Product administration > Dynamic Attributes.
- A child customizable product can contribute to attributes defined on the parent. The parent cannot contribute to attributes defined on the child product. For example, customizable product CP2 is contained within customizable product CP1. CP2 can contribute to attributes defined within CP1. CP1 cannot contribute to attributes defined within CP2.
Use attributes as targets instead of defining multiple resources that keep track of similar variables. This ties the variables directly to a class and makes it easier to keep track of the variables' roles.