Class AbstractProductAndCustomerInputBuilder<T extends AbstractProductAndCustomerInputBuilder,VT>

Object
AbstractInputBuilder<T,VT>
AbstractProductAndCustomerInputBuilder<T,VT>
Direct Known Subclasses:
CustomerInputBuilder, PCGroupInputBuilder, ProductInputBuilder, SellerInputBuilder

public abstract class AbstractProductAndCustomerInputBuilder<T extends AbstractProductAndCustomerInputBuilder,VT> extends AbstractInputBuilder<T,VT>
  • Field Details

    • attributeName

      protected String attributeName
    • filterFormulaName

      protected String filterFormulaName
    • filterFormulaParam

      protected String filterFormulaParam
  • Constructor Details

  • Method Details

    • setAttributeName

      public T setAttributeName(String attributeName)
      Sets the attribute name.

      Example:

      
       def customer = api.inputBuilderFactory()
                        .createCustomerEntry("Customer")
                        .setAttributeName("Test")
       
      Parameters:
      attributeName - Name of the attribute.
      Returns:
      self
    • setFilterFormulaName

      public T setFilterFormulaName(String filterFormulaName)
      Sets a filter logic.
      Specifies which filter logic should be used to filter customers, products, or sellers by.

      Example:

      
       def cg = api.inputBuilderFactory()
                .createCustomerGroupEntry("CustomerGroup")
                .setFilterFormulaName("customerFilter")
                .setLabel("Customer Group")
                .getInput()
      
       return cg
       
      Parameters:
      filterFormulaName - The name of the filter logic that will be used to filter out items displayed by the input field.
      Returns:
      self
      See Also:
    • setFilterFormulaParam

      public T setFilterFormulaParam(String filterFormulaParam)
      Sets a filter logic parameter. The parameter is stored into the filterFormulaParam variable that can be used in filter logic (see the example).

      When more values are passed to the variable, use api.jsonEncode() in the generic logic and then api.jsonDecode() in the filter logic.
      Example:

      Generic Logic Filter logic (nature: customerInputFilter, productInputFilter, sellerInputFilter)
      
       def cg = api.inputBuilderFactory()
                 .createCustomerGroupEntry("CustomerGroup")
                 .setFilterFormulaName("customerFilter")
                 .setFilterFormulaParam(api.jsonEncode(["ProductCategory": "Electronics", "ProductType": "Smartphones"]))
                 .setLabel("Customer Group")
                 .getInput()
      
       return cg
       
      
       def param = api.jsonDecode(filterFormulaParam)
       def productCategory = param?.ProductCategory
       def productType = param?.ProductType
      
       List filters = []
      
       if (Address) {
         filters.add(Filter.equal("attribute1", productCategory))
       }
      
       if (Phone) {
         filters.add(Filter.equal("attribute2", productType))
       }
      
       if (filters.isEmpty()) {
         return null
       }
      
       return Filter.and(*filters)
       
      Parameters:
      filterFormulaParam - A filter logic parameter.
      Returns:
      self
      See Also:
    • getOrCreateFilterFormula

      protected Map<String,Object> getOrCreateFilterFormula()