on 06-23-2016 6:27 PM
I have created a promotion (PromotionSourceRule) via Impex Script and it appears in the back office Rule Engine --> Source Rules. Once I publish them from Backoffice, they are available on the site.
Is there a way, that we can publish the promotion from ImpEx ?
You can write a Groovy script as below to invoke the initializeAllRulesModules(), which publishes the promotions retrieved by the query.
$promotionSourceRulesQuery="select {psr.pk} from {PromotionSourceRule as psr},{PromotionGroup as pg} where {psr.code} in ('3_percent_off_orders_over_500_USD','750_USD_off_orders_over_10000_USD') and {pg.Identifier}='$defaultPromoGrp' and {psr.website}={pg.pk}"
"#%groovy% ruleCompilerService = spring.getBean('ruleCompilerService');
platformRuleEngineService = spring.getBean('platformRuleEngineService');
flexibleSearchService = spring.getBean('flexibleSearchService');
List sourceRules = flexibleSearchService.search($promotionSourceRulesQuery).getResult();
for (sourceRule in sourceRules) { ruleCompilerService.compile(sourceRule); } platformRuleEngineService.initializeAllRulesModules(); ";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In Hybris 6.5: using "ConditionalImportProcessor" and "#% afterEach ..." . Copy/paste in impex file for better readability
$defaultPromoGrp=electronicsPromoGrp
$promotionsModule="promotions-module"
$previewModule="promotions-preview-module"
$ruleImportProcessor=processor=de.hybris.platform.ruleengineservices.impex.impl.ConditionalImportProcessor,condition=de.hybris.platform.ruleengineservices.impex.impl.RuleImportCondition
INSERT_UPDATE PromotionSourceRule[$ruleImportProcessor];&sourceRule;code[unique=true];priority;maxAllowedRuns;stackable[default=false];ruleGroup(code);conditions;actions;website(Identifier)[default=$defaultPromoGrp];excludeFromStorefrontDisplay[default=false];status(code)[unique=true,default=UNPUBLISHED]
"#% afterEach: de.hybris.platform.core.Registry.getApplicationContext().getBean(""ruleEngineSystemSetup"").registerSourceRuleForDeployment(impex.getLastImportedItem(), new String[]{$promotionsModule});"
;percentage_discount_on_sony_camera;percentage_discount_on_sony_camera;210;1;false;productPromotionRuleGroup;"[{""definitionId"":""y_qualifying_categories"",""parameters"":{""quantity"":{""uuid"":""c465645e-fad7-4be4-bee3-b8051e4c686a"",""type"":""java.lang.Integer"",""value"":1},""categories_operator"":{""uuid"":""25370200-6232-4d42-bc30-2115ea86708f"",""type"":""Enum(de.hybris.platform.ruledefinitions.CollectionOperator)"",""value"":""CONTAINS_ANY""},""excluded_categories"":{""uuid"":""e50949f4-2aaf-4316-9704-f99b7308b7fd"",""type"":""List(ItemType(Category))""},""categories"":{""uuid"":""10c31bf0-92ea-464a-94a2-4ab22cb1193b"",""type"":""List(ItemType(Category))"",""value"":[""brand_5""]},""excluded_products"":{""uuid"":""172faee2-676a-415f-912d-5e1dc2bb3ec7"",""type"":""List(ItemType(Product))""},""operator"":{""uuid"":""589693df-111c-4686-bc3e-875d2c82fff5"",""type"":""Enum(de.hybris.platform.ruledefinitions.AmountOperator)"",""value"":""GREATER_THAN_OR_EQUAL""}},""children"":[]}]";"[{""definitionId"":""y_order_entry_percentage_discount"",""parameters"":{""value"":{""uuid"":""f6195d57-a635-4058-9200-e6293e59d7e6"",""type"":""java.math.BigDecimal"",""value"":10}}}]";;true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One solution is to call the RuleCompilerService.compile(AbstractRuleModel rule)
you can get the rule with RuleDao
.
If you want to publish promotion's rule on init you could call these methods from your InitialDataSystemSetup
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jayashree, Did you find any solution? i also need same 🙂
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.