Documentation Home

Rule Builders

Broadleaf provides a customizable admin field called a Rule Builder. This allows the admin user to create a set of conditions that will be dynamically evaluated to identify entities that satisfy these criteria.

Using a Rule Builder

Admin Page

Adding New Rules

Rule Builders are powered through Entity specific FieldServices. Adding new fields requires an override of these classes. Here is two new fields being added to the Product Rule Builders as an example:

    public class ExtendedProductFieldService extends ProductFieldServiceImpl {
        public void init() {
            // Call super to get all existing rules

            // Add new fields below

            fields.add(new FieldData.Builder()
                    .label("Rental") // Display name in Rule Builder set as string
                    .name("rental") // Reflection accessed Java variable name on Product

            fields.add(new FieldData.Builder()
                    .label("rule_manufacturerBrand") // Display name resolved through
                    .name("") // Reflection accessed Many to One Relationship between Product and Manufacturer Brand
                    .operators(RuleOperatorType.SELECTIZE) // Give list of distinct options in a dropdown
                    .selectizeSectionKey("mfg-brand") // Admin Section URL for related entity