How We Add New Rule Condition Parameter

and so on…
$lang = en

INSERT_UPDATE RuleConditionDefinition; id[unique = true] ; name[lang = $lang] ; priority; breadcrumb[lang = $lang] ; allowsChildren; translatorId ; translatorParameters; categories(id)
; y_category_total_quantity ; Category total Quantity ; 700 ; Category {categories} total {operator} {quantity} ; false ; ruleCategoryTotalQuantityConditionTranslator ; ; general

INSERT_UPDATE RuleConditionDefinitionParameter; definition(id)[unique = true]; id[unique = true]; priority; name[lang = $lang] ; description[lang = $lang] ; type ; value ; required[default = true]
; y_category_total_quantity ; brands ; 1150 ; Brands ; List of brands to be evaluated ; List(ItemType(Category)) ; ; false;
RuleParameterData brandsParameter = conditionParameters.get("brands");if (verifyAllPresent(operatorParameter, quantityParameter, categoriesParameter,brandsParameter)) {//add brands parameter variable for verifyAllPresent
List<String> brandCodes = brandsParameter.getValue();//get brands
......//add this method to check product that is contains the brand code or not
RuleIrAttributeCondition createBrandCodeCondition(RuleCompilerContext context, List<String> brands) {
return RuleIrAttributeConditionBuilder.newAttributeConditionFor(context.generateVariable(BrandsRAO.class))
//..and we need to add product brands relation condition
RuleIrAttributeRelCondition createBrandProductRelation(RuleCompilerContext context) {
return RuleIrAttributeRelConditionBuilder.newAttributeRelationConditionFor(context.generateVariable(ProductRAO.class))
.withOperator(RuleIrAttributeOperator.CONTAINS) .withTargetVariable(context.generateVariable(BrandsRAO.class))
<bean class="de.hybris.platform.ruleengineservices.rao.BrandsRAO">
<property name="code" type="String" equals="true"/>
<alias name="defaultBrandsRaoConverter" alias="brandsRaoConverter" />
<bean id="defaultBrandsRaoConverter" parent="abstractPopulatingConverter">
<property name="targetClass" value="de.hybris.platform.ruleengineservices.rao.BrandsRAO" />
<property name="populators">
<ref bean="brandsRaoPopulator"/>

<alias name="defaultBrandsRaoPopulator" alias="brandsRaoPopulator" />
<bean id="defaultBrandsRaoPopulator"
<bean class="de.hybris.platform.ruleengineservices.rao.ProductRAO"
<property name="brands" type="java.util.Set&lt;de.hybris.platform.ruleengineservices.rao.BrandsRAO>" />
<alias name="defaultKarahanProductRaoPopulator" alias="productRaoPopulator" />
<bean id="defaultKarahanProductRaoPopulator" class="" parent="defaultProductRaoPopulator">
<property name="brandsConverter" ref="brandsRaoConverter" /> <property name="karahanCategoryService" ref="karahanCategoryService"/>
//--add brands provider to provide the facts required to evaluate rules and apply actions
<alias name="defaultBrandsRaoProvider" alias="brandsRaoProvider"/>
<bean id="defaultBrandsRaoProvider" class=""/>
//-cart provider extractors run our brandsraoprovider with this line
<bean depends-on="cartRAOProviderExtractors" parent="listMergeDirective">
<property name="add" ref="brandsRaoProvider"/>
public class KarahanProductRaoPopulator extends ProductRaoPopulator {

private KarahanCategoryService karahanCategoryService;
private Converter<CategoryModel, BrandsRAO> brandsConverter;

public void populate(ProductModel source, ProductRAO target) {
super.populate(source, target);
CategoryModel brandModel = karahanCategoryService.getBrand(source);
HashSet<BrandsRAO> brandsCats = new HashSet(Collections.singleton(getBrandsConverter().convert(brandModel)));

public Converter<CategoryModel, BrandsRAO> getBrandsConverter() {
return brandsConverter;

public void setBrandsConverter(Converter<CategoryModel, BrandsRAO> brandsConverter) {
this.brandsConverter = brandsConverter;

public KarahanCategoryService getKarahanCategoryService() {
return karahanCategoryService;

public void setKarahanCategoryService(KarahanCategoryService karahanCategoryService) {
this.karahanCategoryService = karahanCategoryService;
public class BrandsRaoPopulator implements Populator<CategoryModel, BrandsRAO> {

public void populate(CategoryModel source, BrandsRAO target) throws ConversionException {
public class BrandsRaoProvider implements RAOFactsExtractor {

private static final String EXPAND_BRANDS_DEFINITION = "EXPAND_BRANDS";

public Set expandFact(Object fact) {
Preconditions.checkArgument(fact instanceof CartRAO, "CartRAO type is expected here");
Set<Object> facts = new HashSet<>();
CartRAO cartRAO = (CartRAO)fact;
if (CollectionUtils.isNotEmpty(cartRAO.getEntries())) {
for(OrderEntryRAO orderEntryRAO : cartRAO.getEntries()){
ProductRAO productRAO = orderEntryRAO.getProduct();
if(Objects.nonNull(productRAO)) {
return facts;

public String getTriggeringOption() {

public boolean isMinOption() {
return false;

public boolean isDefault() {
return true;

SAP Hybris/Java Spring/PHP Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Competitive Programming: Progress and Insights as a Beginner

7 Common Scrum Myths

Coding Tutor Tip-6-Is Coding For You?

Using Docker Build Strategy on an Enterprise Kubernetes and OpenShift Cluster

Guide to Becoming a Full Stack Developer — Part 1

Opacity — A Flutter Widget — WalkingTree Technologies

Welcome To the Dark (mode).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mehmet Karahan

Mehmet Karahan

SAP Hybris/Java Spring/PHP Developer

More from Medium

Cross-platform [Technical Term]

Configure Tailwind CSS for Vanilla JS with JIT in 10 Easy Steps

All About Azure & Steps to Create Website Using Visual Studio